Permalink
1 comment
on commit
Please
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[libpng16] Fix the calculation of row_factor in png_check_chunk_length
(Bug report by Thuan Pham, SourceForge issue #278)
- Loading branch information
Showing
1 changed file
with
6 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3167,10 +3167,13 @@ png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) | |
| { | ||
| png_alloc_size_t idat_limit = PNG_UINT_31_MAX; | ||
| size_t row_factor = | ||
| (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) | ||
| + 1 + (png_ptr->interlaced? 6: 0)); | ||
| (size_t)png_ptr->width | ||
| * (size_t)png_ptr->channels | ||
| * (png_ptr->bit_depth > 8? 2: 1) | ||
| + 1 | ||
| + (png_ptr->interlaced? 6: 0); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
| if (png_ptr->height > PNG_UINT_32_MAX/row_factor) | ||
This comment has been minimized.
Sorry, something went wrong.
dgutson
|
||
| idat_limit=PNG_UINT_31_MAX; | ||
| idat_limit = PNG_UINT_31_MAX; | ||
| else | ||
| idat_limit = png_ptr->height * row_factor; | ||
| row_factor = row_factor > 32566? 32566 : row_factor; | ||
|
|
||
1 comment
on commit 8a05766
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width cannot exceed PNG_UINT_31_MAX, so adding +1 here is safe.
You can still get a 0 with the following values: