-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
Internal changes only. Move chunk length checks to fewer places: Change `png_struct::user_chunk_malloc_max` to always have a non-zero value, in order to avoid the need to check for zero in multiple places. Add `png_chunk_max(png_ptr)`, a function-like macro defined in pngpriv.h which expresses all the previous checks on the various USER_LIMITS and system limitations. Replace the code which implemented such checks with `png_chunk_max`. Move the malloc limit length check in `png_read_chunk_header` to `png_handle_chunk` and make it conditional on the chunk type. Progressive reader: call `png_read_chunk_header`. Correct the handling of pHYs. Reviewed-by: Cosmin Truta <ctruta@gmail.com> Signed-off-by: John Bowler <jbowler@acm.org> Signed-off-by: Cosmin Truta <ctruta@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,11 +278,18 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, | |
create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; | ||
# endif | ||
|
||
# ifdef PNG_USER_CHUNK_MALLOC_MAX | ||
/* Added at libpng-1.2.43 and 1.4.1, required only for read but exists | ||
* in png_struct regardless. | ||
*/ | ||
# if PNG_USER_CHUNK_MALLOC_MAX > 0 /* default to compile-time limit */ | ||
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; | ||
|
||
/* No compile time limit so initialize to the system limit: */ | ||
# elif (defined PNG_MAX_MALLOC_64K/* legacy system limit */ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ctruta
Member
|
||
create_struct.user_chunk_malloc_max = 65536U; | ||
|
||
# else /* modern system limit SIZE_MAX (C99) */ | ||
create_struct.user_chunk_malloc_max = PNG_SIZE_MAX; | ||
# endif | ||
# endif | ||
|
||
|
Missing ')'?