diff mbox series

[FFmpeg-devel,3/4] avformat/iff: check size against INT64_MAX

Message ID 20201028225643.30485-3-michael@niedermayer.cc
State Accepted
Commit f291cd681b1235e150464ad83974d60d6879b492
Headers show
Series [FFmpeg-devel,1/4] avformat/apngdec: Check for incomplete reads in append_extradata()
Related show

Checks

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

Commit Message

Michael Niedermayer Oct. 28, 2020, 10:56 p.m. UTC
Bigger sizes are misinterpreted as negative numbers by the API
Fixes: infinite loop
Fixes: 26611/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4890614975692800

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

Comments

Michael Niedermayer Nov. 4, 2020, 10:35 p.m. UTC | #1
On Wed, Oct 28, 2020 at 11:56:42PM +0100, Michael Niedermayer wrote:
> Bigger sizes are misinterpreted as negative numbers by the API
> Fixes: infinite loop
> Fixes: 26611/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4890614975692800
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/iff.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/iff.c b/libavformat/iff.c
index 04fe8be4eb..5eee2474ca 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -223,6 +223,9 @@  static int parse_dsd_diin(AVFormatContext *s, AVStream *st, uint64_t eof)
         uint64_t orig_pos = avio_tell(pb);
         const char * metadata_tag = NULL;
 
+        if (size >= INT64_MAX)
+            return AVERROR_INVALIDDATA;
+
         switch(tag) {
         case MKTAG('D','I','A','R'): metadata_tag = "artist"; break;
         case MKTAG('D','I','T','I'): metadata_tag = "title";  break;