Skip to content

Commit

Permalink
Implement code review requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: John Bowler <jbowler@acm.org>
  • Loading branch information
jbowler committed Jan 30, 2025
1 parent 4c24d61 commit 44b8583
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 0 additions & 3 deletions png.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,

/* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
* in png_struct regardless.
*
* 1.6.47: ensure that the field is always set to a non-zero value so that
* it does not have to be checked when used.
*/
# if PNG_USER_CHUNK_MALLOC_MAX > 0 /* default to compile-time limit */
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
Expand Down
11 changes: 6 additions & 5 deletions pngset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,13 +1733,13 @@ png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
if (png_ptr == NULL)
return;

if (size == 0 || size > (uInt)-1)
if (size == 0 || size > PNG_UINT_31_MAX)
png_error(png_ptr, "invalid compression buffer size");

# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_ptr->IDAT_read_size = (uInt)/*SAFE*/size; /* checked above */
png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
return;
}
# endif
Expand Down Expand Up @@ -1831,9 +1831,10 @@ png_set_chunk_malloc_max(png_structrp png_ptr,
{
png_debug(1, "in png_set_chunk_malloc_max");

/* 1.6.47: make it so that user_chunk_malloc_max is never 0 to avoid checking
* everywhere it is used. Setting this value to 1U will have the effect of
* preventing all read-time malloc operations except for reading IDAT.
/* pngstruct::user_chunk_malloc_max is initialized to a non-zero value in
* png.c. This API supports '0' for unlimited, make sure the correct
* (unlimited) value is set here to avoid a need to check for 0 everywhere
* the parameter is used.
*/
if (png_ptr != NULL)
{
Expand Down

0 comments on commit 44b8583

Please sign in to comment.