diff mbox series

[FFmpeg-devel,09/11] avformat/pcm: Check block_align

Message ID 20201020205619.7939-9-michael@niedermayer.cc
State Accepted
Commit b23a619c132a8ad5282a5fd02bfe8b253101c79d
Headers show
Series [FFmpeg-devel,01/11] avcodec/notchlc: Check uncompressed size against input for LZ4 | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 20, 2020, 8:56 p.m. UTC
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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Oct. 25, 2020, 8:59 a.m. UTC | #1
On Tue, Oct 20, 2020 at 10:56:17PM +0200, Michael Niedermayer wrote:
> 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 | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/pcm.c b/libavformat/pcm.c
index 767bbd045a..1effc0b6f8 100644
--- a/libavformat/pcm.c
+++ b/libavformat/pcm.c
@@ -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);