Page 1 of 1

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

Posted: Sun Mar 29, 2009 12:31 pm
by vollmerk
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); 

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

Posted: Sun Mar 29, 2009 1:59 pm
by James Heinrich
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);