diff mbox series

[FFmpeg-devel,04/12] avformat/id3v2: Check the return from avio_get_str()

Message ID 20210131191818.17203-4-michael@niedermayer.cc
State Accepted
Commit 25f240fcb398eb499ca4b70c026a8bb9f2a32731
Headers show
Series [FFmpeg-devel,01/12] avcodec/hevc_sei: Check payload size in decode_nal_sei_message() | expand

Checks

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

Commit Message

Michael Niedermayer Jan. 31, 2021, 7:18 p.m. UTC
Fixes: out of array access
Fixes: 29446/clusterfuzz-testcase-minimized-ffmpeg_dem_AAC_fuzzer-5096222622875648

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

Patch

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 97f6cc8a68..df11b5450c 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -605,7 +605,10 @@  static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
 
     /* mimetype */
     if (isv34) {
-        taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
+        int ret = avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
+        if (ret < 0 || ret >= taglen)
+            goto fail;
+        taglen -= ret;
     } else {
         if (avio_read(pb, mimetype, 3) < 0)
             goto fail;