aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-04-19 20:23:44 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-11 21:23:49 +0200
commit13a3dc95b913fc35229f909e75b687acf183e6dc (patch)
treea3964638c02d6c2a41c7b8c73de0970e12f7954a /libavformat
parent069ea22b51dda3b346842039d0357a6f84c99124 (diff)
downloadffmpeg-13a3dc95b913fc35229f909e75b687acf183e6dc.tar.gz
avformat/id3v2: Check end for overflow in id3v2_parse()
Fixes: signed integer overflow: 9223372036840103978 + 67637280 cannot be represented in type 'long' Fixes: 33341/clusterfuzz-testcase-minimized-ffmpeg_dem_DSF_fuzzer-6408154041679872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit efdb56450418933965dc6e27f0b1625d25e44a8c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/id3v2.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 8f8ffc416f..a1ef29ab01 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -827,7 +827,7 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata,
int isv34, unsync;
unsigned tlen;
char tag[5];
- int64_t next, end = avio_tell(pb) + len;
+ int64_t next, end = avio_tell(pb);
int taghdrlen;
const char *reason = NULL;
AVIOContext pb_local;
@@ -839,6 +839,10 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata,
av_unused int uncompressed_buffer_size = 0;
const char *comm_frame;
+ if (end > INT64_MAX - len - 10)
+ return;
+ end += len;
+
av_log(s, AV_LOG_DEBUG, "id3v2 ver:%d flags:%02X len:%d\n", version, flags, len);
switch (version) {