id3v2: explicitly seek to the end of the tag after reading

Message ID 1300214554-27194-1-git-send-email-anton@khirnov.net
State Superseded
Headers show

Commit Message

Anton Khirnov March 15, 2011, 6:42 p.m.
Current code might stop in the middle of an invalid tag.

fixes issue2650
---
 libavformat/id3v2.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 76c7124..f92f711 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -140,7 +140,7 @@  static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
 {
     int isv34, tlen, unsync;
     char tag[5];
-    int64_t next;
+    int64_t next, end = avio_tell(s->pb) + len;
     int taghdrlen;
     const char *reason;
     AVIOContext pb;
@@ -238,8 +238,9 @@  static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
         avio_seek(s->pb, len, SEEK_CUR);
     }
     if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
-        avio_seek(s->pb, 10, SEEK_CUR);
+        end += 10;
 
+    avio_seek(s->pb, end, SEEK_SET);
     av_free(buffer);
     return;