JamesHeinrich / getID3

http://www.getid3.org/
Other
1.13k stars 245 forks source link

Warning on PrintHexBytes function when $string is not a string. #442

Closed MorganOlufsen closed 2 months ago

MorganOlufsen commented 2 months ago

Somewhere in code this function is called passing a INT on $string. That raises a warning: Trying to access array offset on value of type int on /vagrant/vendor/james-heinrich/getid3/getid3/getid3.lib.php line 36

My workaround was to just return an empty string if is_string($string) == false.

JamesHeinrich commented 2 months ago

I could just hide the warning as you describe, but I'd prefer to fix the problem at the source if possible. Do you have a sample file that triggers this warning? (post here or email info@getid3.org)

MorganOlufsen commented 2 months ago

Sorry for the delay. The code is relatively simple:

$getID3 = new getID3; $fileinfo = $getID3->analyze('video.mp4');

Unfortunately the problem occurs with a specific MP4 file that I cannot pass because it has copyright. I haven't been able to replicate it with another video.

I have made a backtrace in case it is helpful to see which function calls this.

Stack trace:
#0 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2177): getid3_lib::PrintHexBytes()
#1 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#2 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(894): getid3_quicktime->QuicktimeParseContainerAtom()
#3 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#4 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(312): getid3_quicktime->QuicktimeParseContainerAtom()
#5 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#6 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#7 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#8 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#9 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuickDesafortunadamente el problema se da con un fichero MP4 concreto que no puedo pasar por tener derechos de autor. No he conseguido replicarlo con otro video.timeParseAtom()
#10 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#11 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#12 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#13 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(93): getid3_quicktime->QuicktimeParseAtom()
#14 /vagrant/vendor/james-heinrich/getid3/getid3/getid3.php(781): getid3_quicktime->Analyze()
#15 /vagrant/app/models/FileAttachment.php(92): getID3->analyze()

It seems that it receives an int when the function is called from: module.audio-video.quicktime.php(Line 2177)

Here:

if ($atom_structure['ES_DecSpecificInfoTag'] != 0x05) {
    $this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecSpecificInfoTag']).'), at offset '.$atom_structure['offset']);
    break;
}

Video format detected by file command: ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]

I'm not sure if it's relevant, but the only audio track is in the Catalan language.

JamesHeinrich commented 2 months ago

Thanks, PrintHexBytes shouldn't have been used there at all. Fixed in https://github.com/JamesHeinrich/getID3/commit/1192b618a2f32be08b0c95d74f2f33d4682d341d (there was also 3 other similar places where the same error could have occurred).