diff mbox

[FFmpeg-devel,3/5] avcodec/loco: Limit lossy parameter so it is sane and does not overflow

Message ID 20190615220056.21784-3-michael@niedermayer.cc
State Accepted
Commit ce3b0b9066b433564ed3ee3eed3a1e8f2c0834a1
Headers show

Commit Message

Michael Niedermayer June 15, 2019, 10 p.m. UTC
Fixes: 15248/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5087440458481664
Fixes: signed integer overflow: 3 + 2147483647 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/loco.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer June 25, 2019, 10:08 a.m. UTC | #1
On Sun, Jun 16, 2019 at 12:00:54AM +0200, Michael Niedermayer wrote:
> Fixes: 15248/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5087440458481664
> Fixes: signed integer overflow: 3 + 2147483647 cannot be represented in type 'int'
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/loco.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/loco.c b/libavcodec/loco.c
index 741db3bdce..e8c62b8178 100644
--- a/libavcodec/loco.c
+++ b/libavcodec/loco.c
@@ -295,6 +295,11 @@  static av_cold int decode_init(AVCodecContext *avctx)
         avpriv_request_sample(avctx, "LOCO codec version %i", version);
     }
 
+    if (l->lossy > 65536U) {
+        av_log(avctx, AV_LOG_ERROR, "lossy %i is too large\n", l->lossy);
+        return AVERROR_INVALIDDATA;
+    }
+
     l->mode = AV_RL32(avctx->extradata + 4);
     switch (l->mode) {
     case LOCO_CYUY2: