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

Fix index out of bound issue when parsing mp4 segment #3403

Merged

Conversation

percytse
Copy link
Contributor

@percytse percytse commented May 13, 2021

Description

Fixes #3402

Screenshots (optional)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

Checklist:

  • I have signed the Google CLA https://cla.developers.google.com
  • My code follows the style guidelines of this project
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have verified my change on multiple browsers on different platforms
  • I have run ./build/all.py and the build passes
  • I have run ./build/test.py and all tests pass

lib/util/mp4_parser.js Outdated Show resolved Hide resolved
@joeyparrish
Copy link
Member

Thank you for contributing!

@joeyparrish joeyparrish added type: bug Something isn't working correctly priority: P1 Big impact or workaround impractical; resolve before feature release labels May 13, 2021
@percytse percytse requested a review from joeyparrish May 14, 2021 03:24
@@ -111,6 +111,12 @@ shaka.util.Mp4Parser = class {
parseNext(absStart, reader, partialOkay, stopOnPartial) {
const start = reader.getPosition();

// size(4 bytes) + type(4 bytes) = 8 bytes
if (stopOnPartial && start + 8 >= reader.getLength()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think == should be fine, right? If a box had only the required size & name fields, start + 8 == reader.getLength() should be acceptable. Do you agree? Should this become > instead of >=?

Also, it looks like a similar check is needed below, when we handle FULL_BOX types and read versionAndFlags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree start + 8 == reader.getLength() should be acceptable.

@percytse percytse requested a review from joeyparrish May 15, 2021 08:32
@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit e02d28c into shaka-project:master May 17, 2021
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MEDIA.BUFFER_READ_OUT_OF_BOUNDS when parsing segment in LL-Dash
3 participants