I have an ID3 file that was causing a crash (memory allocation error). Tracking in to it, the file has an USLT frame with an incorrect length -- it is actually one byte longer than stated in the frame length. So when the library tried to read the next frame it was a byte off and went kinda crazy.
Although the frame was incorrect, the crash could be avoided by a simple change in the Id3v2.php file. At line 188, right after the check for the first character === 0 you can check to see if the character is A-Z or 0-9, as required for all frame identifiers according to the ID3 spec. So adding a line like this:
if (!ctype_digit($identifier[0]) && !ctype_upper($identifier[0])) continue;
Gets past the errant byte and allows the following frames to be read. Obviously there are other potential errors that this wouldn't fix, but I believe this is a safe and legitimate check to perform on the $identifier.
Comment #1
Posted on Apr 17, 2015 by Happy BirdRelated to this, I added the following to Reader.php to prevent memory allocation crashes when things do somehow get out of sync. This allows the calling program to catch the error and recover in whatever way is appropriate...
public function read($length)
{
// SSP: Added sanity check
if ($length > 65535) {
require_once('Zend/Io/Exception.php');
throw new Zend_Io_Exception("Unable to read more than 65535 bytes, $length requested.");
}
...
Status: New
Labels:
Type-Defect
Priority-Medium