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 248 #251

Merged
merged 2 commits into from
Jul 14, 2016
Merged

Fix 248 #251

merged 2 commits into from
Jul 14, 2016

Conversation

oerdnj
Copy link
Contributor

@oerdnj oerdnj commented Jul 12, 2016

fixes output buffer overflow in #248

@oerdnj
Copy link
Contributor Author

oerdnj commented Jul 12, 2016

@cmb69 Please review, if you have a tad bit time.

for (i = 0; i < encoded_pixels; i++) {
for (j = 0; j < pixel_block_size; j++, bitmap_caret++) {
tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ];
if (encoded_pixels > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

encoded_pixels is declared as uint8_t, so this would always be true. Either the if statement is useless, or it should be encoded_pixels < 128. Same issue below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it won't be always true, but it could be changed to if (encoded_pixels != 0) for clarity. (It might also be an useless optimization as encoded_pixels would be always != 0 in normal case).

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, it won't be always true, […]

Of course! Sorry for the noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to != 0 anyway to make more clear (although I suspect any decent compiler would do that for me anyway).

@cmb69
Copy link
Contributor

cmb69 commented Jul 12, 2016

While I assumed that bug00248.tga is corrupt, both Gimp and Imagick's display open it without warning (contrary to bug00247.tga). Not sure, if Gimp and Imagick do advanced error correction here.

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

3 participants