diff mbox series

[FFmpeg-devel,2/2] avformat/rmdec: sanity check coded_framesize

Message ID 20200816180409.20439-2-michael@niedermayer.cc
State Accepted
Commit aee8477c6ba20469ebe531448d31c642717b5f48
Headers show
Series [FFmpeg-devel,1/2] tools/target_dec_fuzzer: Adjust threshold for DST
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer Aug. 16, 2020, 6:04 p.m. UTC
Fixes: signed integer overflow: -14671840 * 8224 cannot be represented in type 'int'
Fixes: 24793/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5101884323659776

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

Comments

Michael Niedermayer Oct. 18, 2020, 7:18 p.m. UTC | #1
On Sun, Aug 16, 2020 at 08:04:09PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -14671840 * 8224 cannot be represented in type 'int'
> Fixes: 24793/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5101884323659776
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/rmdec.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index a36e693ab2..9bb11149e2 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -162,7 +162,11 @@  static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
         avio_rb16(pb); /* version2 */
         avio_rb32(pb); /* header size */
         flavor= avio_rb16(pb); /* add codec info / flavor */
-        ast->coded_framesize = coded_framesize = avio_rb32(pb); /* coded frame size */
+        coded_framesize = avio_rb32(pb); /* coded frame size */
+        if (coded_framesize < 0)
+            return AVERROR_INVALIDDATA;
+        ast->coded_framesize = coded_framesize;
+
         avio_rb32(pb); /* ??? */
         bytes_per_minute = avio_rb32(pb);
         if (version == 4) {