]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/agm: Fix integer overflow with w/h
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 4 Apr 2019 22:20:33 +0000 (00:20 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 5 Apr 2019 10:05:47 +0000 (12:05 +0200)
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 13999/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5644405991538688
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/agm.c

index 2d2092222de3fb1571c3ef468e72ed9e74132308..cbd45e8095ea5a2559d396dcbcda772496a57ccc 100644 (file)
@@ -535,11 +535,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
     s->flags = 0;
     w = bytestream2_get_le32(gbyte);
+    h = bytestream2_get_le32(gbyte);
+    if (w == INT32_MIN || h == INT32_MIN)
+        return AVERROR_INVALIDDATA;
     if (w < 0) {
         w = -w;
         s->flags |= 2;
     }
-    h = bytestream2_get_le32(gbyte);
     if (h < 0) {
         h = -h;
         s->flags |= 1;