Bug in module.tag.apetag.php function getid3_apetag()

Think you found a bug in getID3()? Post here with details.
Post Reply
lubot

Bug in module.tag.apetag.php function getid3_apetag()

Post by lubot » Wed Jan 21, 2004 6:25 pm

Version: 1.70
File: module.tag.apetag.php
Function: getid3_apetag
Line: 30

The Problem:
The following will be true if the whole APE tag is 160 bytes long, even if there is no ID3 tag. this results in a wrong ['avdataend'].
[php]if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') [/php]

Fix
Use the commented code which is already there :)
[php]//if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {[/php]

module.tag.apetag.php
[php]
function getid3_apetag(&$fd, &$ThisFileInfo, $overrideendoffset=0) {
$id3v1tagsize = 128;
$apetagheadersize = 32;
$lyrics3tagsize = 10;

...

fseek($fd, 0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);
$APEfooterID3v1 = fread($fd, $id3v1tagsize + $apetagheadersize + $lyrics3tagsize);

//if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {
if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') {

// APE tag found before ID3v1
$ThisFileInfo['ape']['tag_offset_end'] = $ThisFileInfo['filesize'] - $id3v1tagsize;

//} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) {
} elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') {

// APE tag found, no ID3v1
$ThisFileInfo['ape']['tag_offset_end'] = $ThisFileInfo['filesize'];
}
...[/php]

Post Reply