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

metadata: validate min chunk length for jpeg #346

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

sscobici
Copy link

fixes panic

@sscobici sscobici force-pushed the metadata-fix branch 2 times, most recently from 9015455 to c5b3540 Compare January 18, 2025 19:17
Comment on lines 85 to 87
if chunk_len < 2 {
return decode_error("meta (jpeg): invalid chunk length");
}
Copy link
Owner

Choose a reason for hiding this comment

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

Looking further into JPEG, it looks like there are some chunks that don't actually have a length (they're just markers essentially) 1. These are chunk_types 0xd0 to 0xd9, inclusive.

After line 66, can you add a continue if any of these chunk types are encountered?
Then, please move this check to after line 67 where chunk_len is read, since a length < 2 is just invalid entirely.

Footnotes

  1. https://github.com/corkami/formats/blob/master/image/jpeg.md

@sscobici
Copy link
Author

fixed

@pdeljanov pdeljanov merged commit 9f97410 into pdeljanov:dev-0.6 Jan 18, 2025
11 checks passed
@pdeljanov
Copy link
Owner

Thank you!

@sscobici sscobici deleted the metadata-fix branch January 18, 2025 20:55
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.

2 participants