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: rewrite illustration check to not use regex #358

Closed
wants to merge 1 commit into from

Conversation

shenlebantongying
Copy link

fix #352 by not using regex on binary data.

@shenlebantongying shenlebantongying changed the title fix: rewrite illustration to not use regex fix: rewrite illustration check to not use regex Jul 1, 2023
@kelson42 kelson42 requested a review from mgautierfr July 1, 2023 20:24

const std::string& illustration = data["Illustration_48x48@1"];

if (illustration.length() >= 24) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this test needed? What's wrong with always (unconditionally) testing the first 8 bytes?

// In PNG file, 16-20 is width and 20-24 is height in big endian order.
const std::string png48x48 = {0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30};

if (illustration.substr(16, 8) != png48x48) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

illustration.substr(16, 8) will throw if illustration.length() < 16

@kelson42
Copy link
Contributor

kelson42 commented Aug 4, 2023

@shenlebantongying Any news?

@kelson42
Copy link
Contributor

@mgautierfr Can you please fix PR

@kelson42
Copy link
Contributor

kelson42 commented Sep 22, 2023

After #369 has been merged this should be rebased and readapted to benefit from the illustration size check

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.

Large --illustration image size lead to SIGSEGV
3 participants