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

Improved stability for mp4 parser when dealing with corrupted FTYP boxes #241

Merged
merged 3 commits into from
Sep 19, 2023

Conversation

rcpalacio
Copy link
Contributor

About the issue

Every MP4 file should start with a ftyp box. We rely on that to build a check for magic bytes and return early from the parser.

The problem arises when a file matches the header of a ftyp box but don't actually describe the box correctly -- for instance, bringing a wrong box size. In that case, the box can't be parsed and the file should be discarded.
What happens instead is that, due to an issue with the safe navigation, the parser would still try to read from the missing box, resulting in the error NoMethodError: undefined method []' for nil:NilClass`.

… MP4 parser to throw errors instead of rejecting the files
Copy link
Contributor

@linkyndy linkyndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting and fixing this! 🔧

spec/parsers/mp4_parser_spec.rb Show resolved Hide resolved
@rcpalacio rcpalacio merged commit 2d9456d into master Sep 19, 2023
12 checks passed
@RubenWolff-wt RubenWolff-wt deleted the MP4_parser_stability_for_non-compliant_files branch September 20, 2023 08:35
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

Successfully merging this pull request may close these issues.

None yet

3 participants