Mp3Info icon indicating copy to clipboard operation
Mp3Info copied to clipboard

Division by zero

Open painbaker opened this issue 1 year ago • 4 comments

DivisionByZeroError: Division by zero in ..\vendor\wapmorgan\mp3info\src\Mp3Info.php at line 425

Sample file: https://drive.google.com/open?id=11IrcdfEWlSTGwwXgf-yro2Hgjk3CV15M&usp=drive_fs

0.1.0

painbaker avatar Jun 22 '23 11:06 painbaker

I experience the same problem!

jeroen-fonky avatar Jul 18 '23 09:07 jeroen-fonky

Another one

DivisionByZeroError: Division by zero ...\vendor\wapmorgan\mp3info\src\Mp3Info.php:327

https://drive.google.com/open?id=13RITkPPiovgwDMefsBAPf7Zz8i4NohKW&usp=drive_fs

painbaker avatar Jan 09 '24 23:01 painbaker

Same here: https://github.com/wapmorgan/Mp3Info/blob/master/src/Mp3Info.php#L323

painbaker avatar Jan 11 '24 22:01 painbaker

Same with http://archives.bassdrivearchive.com/6%20-%20Saturday/Electronic%20Warfare%20-%20The%20Overfiend/%5b2023.03.11%5d%20Electronic%20Warfare%20-%20Overfiend.mp3

(File opened via url/http - not locally!)

PHP Fatal error:  Uncaught DivisionByZeroError: Division by zero in Mp3Info-0.1.0/src/Mp3Info.php:425

What I've traced so far:

  • $this->codecVersion is 2.
  • $header_bytes are 255, 247, 31, 219 (or FF F7 1F DB)
  • the ($header_bytes[2] >> 2) & 0b11 turns into 3
  • self::$_sampleRateTable[3] is false ("reserved" according to spec)
  • therefore, $this->sampleRate gets set to false which causes the DivisionByZeroError later

EDIT: A workaround for me seems to be checking $this->sampleRate right after line 388, and if it turns out to be false, just do a return null. Which will make Mp3Info read the next frame. This issue might be related to #13 - just that the first frame is giving invalid data here.

mbirth avatar Feb 25 '24 20:02 mbirth