Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) #315

Closed
paulijar opened this issue May 13, 2021 · 2 comments

Comments

@paulijar
Copy link
Contributor

I got a report from an end user that a few of his files are breaking the file scanning. I got also a sample file which I shall email shortly. The error message indicates that the scanning is terminated at

$frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset);
because of the reason shown in the issue title. That is, the $frame_offset goes beyond the end of the target data buffer.

This actually terminates the file analysis only when PHP 8.0 is used, because there, the platform throws a ValueError on invalid argument value. On PHP 7.x, this just emits a warning and the file analysis continues and returns valid-looking data.

The original report is here: owncloud/music#856

@JamesHeinrich
Copy link
Owner

Thanks for the sample file, fixed in 897de38.

The file has a badly-written "USLT" (lyrics) frame. The frame requires at a minimum 5 bytes (1x encoding, 3x language, 1x description/data terminator) even if the frame contains no actual data, but the sample file has the frame stop after the encoding byte. I have added a check for sufficient data before attempting to parse it.

@paulijar
Copy link
Contributor Author

Thanks! Your response time was astonishing as always. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants