summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-11-10 12:26:26 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-11-10 12:26:26 +0000
commit00651929025b570baa7d06d85881300472ffef63 (patch)
treeef433272fd2e1547e0ed8a7e9e95562ded1ee4c0
parentcdc2c3b653e0d9bd01d1af3dbd7cd568de1a32e9 (diff)
downloadrockbox-00651929025b570baa7d06d85881300472ffef63.tar.gz
rockbox-00651929025b570baa7d06d85881300472ffef63.zip
Made the PSID metadata parser a little less trusting of its input.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11500 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/metadata.c b/apps/metadata.c
index 03141d05c7..2f00787e6f 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -1419,6 +1419,8 @@ static bool get_musepack_metadata(int fd, struct mp3entry *id3)
1419 return true; 1419 return true;
1420} 1420}
1421 1421
1422/* PSID metadata info is available here:
1423 http://www.unusedino.de/ec64/technical/formats/sidplay.html */
1422static bool get_sid_metadata(int fd, struct mp3entry* id3) 1424static bool get_sid_metadata(int fd, struct mp3entry* id3)
1423{ 1425{
1424 /* Use the trackname part of the id3 structure as a temporary buffer */ 1426 /* Use the trackname part of the id3 structure as a temporary buffer */
@@ -1440,22 +1442,27 @@ static bool get_sid_metadata(int fd, struct mp3entry* id3)
1440 1442
1441 p = id3->id3v2buf; 1443 p = id3->id3v2buf;
1442 1444
1443 /* Copy Title */ 1445 /* Copy Title (assumed max 0x1f letters + 1 zero byte) */
1444 strcpy(p, (char *)&buf[0x16]); 1446 strncpy(p, (char *)&buf[0x16], 0x20);
1447 p[0x1f]=0; /* make sure it is zero terminated */
1445 id3->title = p; 1448 id3->title = p;
1446 p += strlen(p)+1; 1449 p += strlen(p)+1;
1447 1450
1448 /* Copy Artist */ 1451 /* Copy Artist (assumed max 0x1f letters + 1 zero byte) */
1449 strcpy(p, (char *)&buf[0x36]); 1452 strncpy(p, (char *)&buf[0x36], 0x20);
1453 p[0x1f]=0; /* make sure it is zero terminated */
1450 id3->artist = p; 1454 id3->artist = p;
1451 p += strlen(p)+1;
1452 1455
1453 id3->bitrate = 706; 1456 id3->bitrate = 706;
1454 id3->frequency = 44100; 1457 id3->frequency = 44100;
1455 /* New idea as posted by Marco Alanen (ravon): 1458 /* New idea as posted by Marco Alanen (ravon):
1456 * Set the songlength in seconds to the number of subsongs 1459 * Set the songlength in seconds to the number of subsongs
1457 * so every second represents a subsong. 1460 * so every second represents a subsong.
1458 * Users can then skip the current subsong by seeking */ 1461 * Users can then skip the current subsong by seeking
1462 *
1463 * Note: the number of songs is a 16bit value at 0xE, so this code only
1464 * uses the lower 8 bits of the counter.
1465 */
1459 id3->length = (buf[0xf]-1)*1000; 1466 id3->length = (buf[0xf]-1)*1000;
1460 id3->vbr = false; 1467 id3->vbr = false;
1461 id3->filesize = filesize(fd); 1468 id3->filesize = filesize(fd);