]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/id3v2.c
avformat/id3v2: Check end for overflow in id3v2_parse()
[ffmpeg] / libavformat / id3v2.c
index e0fef087891aebfbc88066f1e7a8f32f1be4eafc..96226193c1dd74cd3cc7cb41acc87f3d47b89441 100644 (file)
@@ -824,7 +824,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;
@@ -836,6 +836,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) {