uncaught error / tweak to module.audio.mp3.php

Locked
vollmerk
User
Posts: 18
Joined: Wed Jun 14, 2006 9:42 pm

uncaught error / tweak to module.audio.mp3.php

Post by vollmerk » Sun Mar 29, 2009 12:31 pm

Unfortunately I don't have the file in question, but in response to http://ampache.org/forums/viewtopic.php?pid=13297 I made the following modification (http://ampache.org/bugs/changeset/2019) I didn't really look at the code so this might be the horribly wrong way to go about it, but it should prevent the above mentioned php error. This was applied against the latest 'released' version of getid3() 2.x

Code: Select all

1077	1077	         
1078	1078	        $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdata_offset); 
 	1079	        // If sync < 1 then resort to default of 128 * 1024 
 	1080	        if ($sync_seek_buffer_size < 1) { $sync_seek_buffer_size = 128 * 1024; } 
1079	1081	        $header = fread($fd, $sync_seek_buffer_size); 
1080	1082	        $sync_seek_buffer_size = strlen($header); 

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: uncaught error / tweak to module.audio.mp3.php

Post by James Heinrich » Sun Mar 29, 2009 1:59 pm

v1.7.x has a check in there to catch this condition, but v2.x did not. I believe the problem is (at first glance without actually testing anything) when reading over the network the info[avdataend] key may not be set to the filesize-end_tags_size, and you may end up with $sync_seek_buffer_size <= 0.

My solution for v2.0.0b6 is this; your code should do equally well:

Code: Select all

        $databytes = $info['avdataend'] - $avdata_offset;
        $sync_seek_buffer_size = 128 * 1024;
        if ($databytes > 2000) { // not an exact amount, just picked this number cause it seemed reasonable
        	$sync_seek_buffer_size = min($databytes, $sync_seek_buffer_size);
        }
        $header = fread($fd, $sync_seek_buffer_size);

Locked