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

Message ID 1300342223-17158-1-git-send-email-anton@khirnov.net
State Committed
Commit bca6dee386307e4f3646632d98a9db87ce9de249
Headers show

Commit Message

Anton Khirnov March 17, 2011, 6:10 a.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(-)

Comments

Ronald Bultje March 21, 2011, 6:57 p.m. | #1
Hi,

On Thu, Mar 17, 2011 at 2:10 AM, Anton Khirnov <anton@khirnov.net> wrote:
> Current code might stop in the middle of an invalid tag.
>
> fixes issue2650
> ---
>  libavformat/id3v2.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)

Queued.

Ronald

Patch

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index b288ec6..4a2e94b 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -186,7 +186,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;
@@ -284,8 +284,9 @@  static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
         avio_skip(s->pb, len);
     }
     if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
-        avio_skip(s->pb, 10);
+        end += 10;
 
+    avio_seek(s->pb, end, SEEK_SET);
     av_free(buffer);
     return;