strpos(): Offset not contained in string

Locked
Lenton
User
Posts:8
Joined:Fri Jul 08, 2011 2:14 pm
Are you a spambot?:no
strpos(): Offset not contained in string

Post by Lenton » Thu Jul 14, 2011 11:45 am

When getting basic information from MP3 files I sometimes get this error:
PHP Warning: strpos(): Offset not contained in string in /home/user/Documents/getid3/module.tag.id3v2.php on line 1250
Note: I'm using the script for getting MP3s from remote servers.

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

Re: strpos(): Offset not contained in string

Post by James Heinrich » Thu Jul 14, 2011 12:32 pm

Sounds like you're probably grabbing 32kB of the file, and dealing with a file that has a large ID3v2 tag with embedded images (which could range anywhere from a few kB to a few MB). getID3() should normally fail gracefully when it finds invalid/truncated data, but this may be a borderline case where it does not. Please send me the URL for a sample file that does this (either post here to PM me).

Lenton
User
Posts:8
Joined:Fri Jul 08, 2011 2:14 pm
Are you a spambot?:no

Re: strpos(): Offset not contained in string

Post by Lenton » Thu Jul 14, 2011 2:18 pm

I found the links that error and they all seem to not work. Here's a link if you still need it:

http://dc266.4shared.com/img/694985495/ ... review.mp3

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

Re: strpos(): Offset not contained in string

Post by James Heinrich » Thu Jul 14, 2011 2:31 pm

I am able to replicate the error with your supplied link, I will investigate and let you know.

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

Re: strpos(): Offset not contained in string

Post by James Heinrich » Sun Jul 17, 2011 10:28 pm

Whatever program was used to tag that file is not doing it correctly. Two problems I found:
  • ID3v2 tag length field is incorrect: the value is written as 167 bytes, but should be 157 bytes (the ID3v2 tag is 167 bytes long, but the 10-byte tag header is not included in the tag size field:
    http://id3.org/id3v2.3.0#head-697d09c50 ... 85e2652b0b
    The ID3v2 tag size is the size of the complete tag after unsychronisation, including padding, excluding the header but not excluding the extended header (total tag size - 10).
    This means the first frame of the MP3 file is skipped (which is where a VBR header would be, if present), and a false warning about invalid ID3v2 padding is generated.
  • There is an APIC (Attached PICture) frame, which contains a MIME type (image/jpeg) but no actual image data (nor picture type flag nor description). This is also not legal according to the ID3v2 specs, and it's this brokenness that generated the "offset not contained in string" warning. I've added a check into getID3() v1.9.1 to counter this odd and rare malformation, but it's a broken tag not a getID3() bug.

Locked