From fd3d50a4db38758b880908e6eb5a8601d2c10a9c Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 29 Oct 2002 10:29:57 +0000 Subject: [PATCH] Better handling of large frames in V2 tags git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2771 a1c6a512-1295-4272-9138-f99709370657 --- firmware/id3.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/firmware/id3.c b/firmware/id3.c index e59618e234..f09ccf4ab2 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -223,7 +223,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry) /* * Sets the title of an MP3 entry based on its ID3v2 tag. * - * Arguments: file - the MP3 file to scen for a ID3v2 tag + * Arguments: file - the MP3 file to scan for a ID3v2 tag * entry - the entry to set the title in * * Returns: true if a title was found and created, else false @@ -291,7 +291,7 @@ static void setid3v2title(int fd, struct mp3entry *entry) } /* Keep track of the total size */ - totframelen += framelen; + totframelen = framelen; if(framelen == 0) return; @@ -300,7 +300,7 @@ static void setid3v2title(int fd, struct mp3entry *entry) to read as much as would fit in the buffer */ if(framelen >= buffersize - bufferpos) framelen = buffersize - bufferpos - 1; - + /* Check for certain frame headers */ if(!strncmp(header, "TPE1", strlen("TPE1")) || !strncmp(header, "TP1", strlen("TP1"))) { @@ -337,6 +337,12 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 1; size -= bytesread; } + else { + /* Unknown frame, skip it using the total size in case + it was truncated */ + size -= totframelen; + lseek(fd, totframelen, SEEK_CUR); + } } }