mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
IDAT read buffering correction
The sequential read code failed to read to the end of the IDAT stream in about 1/820 cases, resulting in a spurious warning. The png_set_compression_buffer_size API also would not work (or do bad things) if the size of a zlib uInt was less than 32 bits. This includes a quiet API change to alter png_set_compression_buffer_size to use a png_alloc_size_t, not png_size_t and implement the correct checks. Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
7
pngset.c
7
pngset.c
@@ -1596,16 +1596,17 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
png_set_compression_buffer_size(png_structrp png_ptr, png_alloc_size_t size)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (size == 0 || size > PNG_UINT_31_MAX)
|
||||
if (size == 0 ||
|
||||
size > (png_ptr->read_struct ? ZLIB_IO_MAX : PNG_UINT_31_MAX))
|
||||
png_error(png_ptr, "invalid compression buffer size");
|
||||
|
||||
# if (defined PNG_SEQUENTIAL_READ_SUPPORTED) || defined PNG_WRITE_SUPPORTED
|
||||
png_ptr->IDAT_size = (uInt)/*SAFE*/size;
|
||||
png_ptr->IDAT_size = (png_uint_32)/*SAFE*/size;
|
||||
# endif /* SEQUENTIAL_READ || WRITE */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user