1
0
Fork 0
forked from len0rd/rockbox

Submit FS11960. Limit metadata item size like done for ID3 tags since r29174.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29377 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-02-22 07:52:21 +00:00
parent 1203befa08
commit 6cc02bca06
2 changed files with 7 additions and 3 deletions

View file

@ -344,6 +344,7 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3,
{ {
len = strlen(value); len = strlen(value);
len = MIN(len, buf_remaining - 1); len = MIN(len, buf_remaining - 1);
len = MIN(len, ID3V2_MAX_ITEM_SIZE); /* Limit max. item size. */
if (len > 0) if (len > 0)
{ {

View file

@ -122,9 +122,12 @@ static unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer,
* of multiple entries is used, all following are dropped. */ * of multiple entries is used, all following are dropped. */
if (*dest == NULL) if (*dest == NULL)
{ {
(*buffer)[bytes_read] = 0; (*buffer)[bytes_read] = 0; /* zero-terminate for correct strlen().*/
*dest = *buffer;
length = strlen(*buffer) + 1; length = strlen(*buffer) + 1;
length = MIN(length, ID3V2_MAX_ITEM_SIZE); /* Limit item size. */
*dest = *buffer;
(*buffer)[length-1] = 0; /* zero-terminate buffer. */
*buffer_left -= length; *buffer_left -= length;
*buffer += length; *buffer += length;
} }
@ -518,7 +521,7 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3,
char* any = NULL; char* any = NULL;
unsigned int length = read_mp4_tag_string(fd, size, unsigned int length = read_mp4_tag_string(fd, size,
&buffer, &buffer_left, &any); &buffer, &buffer_left, &any);
if (length > 0) if (length > 0)
{ {
/* Re-use the read buffer as the dest buffer... */ /* Re-use the read buffer as the dest buffer... */