forked from len0rd/rockbox
Fix FS#12266, by skipping empty frames when reading ID3v2 tags. Also add some length checks to be safe.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30550 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c222f38c03
commit
e995d01570
1 changed files with 12 additions and 8 deletions
|
|
@ -579,7 +579,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
|
||||||
if(str[1] == 0)
|
if(str[1] == 0)
|
||||||
le = true;
|
le = true;
|
||||||
|
|
||||||
do {
|
while ((i < *len) && (str[0] || str[1])) {
|
||||||
if(le)
|
if(le)
|
||||||
utf8 = utf16LEdecode(str, utf8, 1);
|
utf8 = utf16LEdecode(str, utf8, 1);
|
||||||
else
|
else
|
||||||
|
|
@ -587,7 +587,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
|
||||||
|
|
||||||
str+=2;
|
str+=2;
|
||||||
i += 2;
|
i += 2;
|
||||||
} while((str[0] || str[1]) && (i < *len));
|
}
|
||||||
|
|
||||||
*utf8++ = 0; /* Terminate the string */
|
*utf8++ = 0; /* Terminate the string */
|
||||||
templen += (strlen(&utf8buf[templen]) + 1);
|
templen += (strlen(&utf8buf[templen]) + 1);
|
||||||
|
|
@ -962,10 +962,10 @@ void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
if((tr->tag_length == 4 && !memcmp( header, "COMM", 4)) ||
|
if((tr->tag_length == 4 && !memcmp( header, "COMM", 4)) ||
|
||||||
(tr->tag_length == 3 && !memcmp( header, "COM", 3))) {
|
(tr->tag_length == 3 && !memcmp( header, "COM", 3))) {
|
||||||
int offset;
|
int offset;
|
||||||
if(!strncmp(tag+4, "iTun", 4)) {
|
if(bytesread >= 8 && !strncmp(tag+4, "iTun", 4)) {
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
/* check for iTunes gapless information */
|
/* check for iTunes gapless information */
|
||||||
if(!strncmp(tag+4, "iTunSMPB", 8))
|
if(bytesread >= 12 && !strncmp(tag+4, "iTunSMPB", 8))
|
||||||
itunes_gapless = true;
|
itunes_gapless = true;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1000,6 +1000,10 @@ void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
bytesread--;
|
bytesread--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bytesread == 0)
|
||||||
|
/* Skip empty frames */
|
||||||
|
break;
|
||||||
|
|
||||||
tag[bytesread] = 0;
|
tag[bytesread] = 0;
|
||||||
bufferpos += bytesread + 1;
|
bufferpos += bytesread + 1;
|
||||||
|
|
||||||
|
|
@ -1040,10 +1044,6 @@ void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
#endif
|
#endif
|
||||||
if( tr->ppFunc )
|
if( tr->ppFunc )
|
||||||
bufferpos = tr->ppFunc(entry, tag, bufferpos);
|
bufferpos = tr->ppFunc(entry, tag, bufferpos);
|
||||||
|
|
||||||
/* Seek to the next frame */
|
|
||||||
if(framelen < totframelen)
|
|
||||||
lseek(fd, totframelen - framelen, SEEK_CUR);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1059,6 +1059,10 @@ void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
if( lseek(fd, totframelen, SEEK_CUR) == -1 )
|
if( lseek(fd, totframelen, SEEK_CUR) == -1 )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* Seek to the next frame */
|
||||||
|
if(framelen < totframelen)
|
||||||
|
lseek(fd, totframelen - framelen, SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue