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

Potential buffer overflow (integer overflow for insane image sizes) #14

Closed
auriocus opened this issue Dec 26, 2020 · 2 comments
Closed

Comments

@auriocus
Copy link
Collaborator

Here, the size of the image buffer is computed by 32bit signed integer math, which may lead to overflow for insane settings of width and height, or e.g. -scale:

imgData = (unsigned char *)attemptckalloc(w * h *4);

Due to the integer wrap-around, it may result in the successful allocation of a small buffer. Suggested fix: Use 64bit math, e.g.

(size_t)w * (size_t) h
and check for overflow (painful). Or don't use ckalloc, but malloc.

@oehhar
Copy link
Owner

oehhar commented Jan 6, 2021

Thank you, Christian, great !

May I ask you to continue the discussion on tk core, as the issue is also present there:

https://core.tcl-lang.org/tk/info/822330269bd1da07

Thank you,
Harald

oehhar added a commit that referenced this issue Jan 9, 2021
@oehhar
Copy link
Owner

oehhar commented Jan 9, 2021

I hope it is fixed by the following commit:
[https://github.com/oehhar/tksvg/commit/0d31f12f0d238aab9efb5621196ebaca2f22f4ab]

Thank you,
Harald

@oehhar oehhar closed this as completed Jan 9, 2021
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