Navigation Menu

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

Handle sprintf() appending a NUL byte [issues 53 and 54] #57

Closed
wants to merge 1 commit into from
Closed

Handle sprintf() appending a NUL byte [issues 53 and 54] #57

wants to merge 1 commit into from

Conversation

jmoellers
Copy link

sprintf() always appends a NUL byte to whatever it writes to the destination string.
If the image dimensions are 0x0, then no image data is written and space is allocated only for the headers in export_tga() and export_tiff(). This will lead to a buffer overflow when the last byte(s) of this header are written to using sprintf().
So, in export_tga() put the data into the buffer using plain pointer operations (*ptr++ = ...),
in export_tiff() allocate one additional byte for the NUL byte.

@samhocevar
Copy link
Contributor

Thanks for taking the time to write this patch, and sorry for not following up sooner. I decided to fix the issue in a slightly different way (ab04483).

@samhocevar samhocevar closed this Oct 19, 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

Successfully merging this pull request may close these issues.

None yet

2 participants