]> git.sesse.net Git - ffmpeg/commitdiff
avformat/pcm: Check block_align
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 20 Oct 2020 19:44:32 +0000 (21:44 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 25 Oct 2020 08:49:31 +0000 (09:49 +0100)
Fixes: signed integer overflow: 321 * 8746632 cannot be represented in type 'int'
Fixes: 26461/clusterfuzz-testcase-minimized-ffmpeg_dem_PVF_fuzzer-6326427831762944
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/pcm.c

index 767bbd045a9945d2f062710d848c818b21baea5d..1effc0b6f8d60c80d15ec4ebfc6e0461fdc9395b 100644 (file)
@@ -39,7 +39,11 @@ int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
      * Clamp to RAW_SAMPLES if larger.
      */
     size = FFMAX(par->sample_rate/25, 1);
-    size = FFMIN(size, RAW_SAMPLES) * par->block_align;
+    if (par->block_align <= INT_MAX / RAW_SAMPLES) {
+        size = FFMIN(size, RAW_SAMPLES) * par->block_align;
+    } else {
+        size = par->block_align;
+    }
 
     ret = av_get_packet(s->pb, pkt, size);