mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Harden a vestigial check against overflow inside png_zalloc
Reported-by: Sergio Atienza Pastor, MTP Métodos y Tecnología
This commit is contained in:
parent
cf59edd364
commit
7cecdcae07
8
png.c
8
png.c
@ -108,7 +108,13 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (items >= (~(png_alloc_size_t)0)/size)
|
||||
/* This check against overflow is vestigial, dating back from
|
||||
* the old times when png_zalloc used to be an exported function.
|
||||
* We're still keeping it here for now, as an extra-cautious
|
||||
* prevention against programming errors inside zlib, although it
|
||||
* should rather be a debug-time assertion instead.
|
||||
*/
|
||||
if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
|
||||
{
|
||||
png_warning(png_voidcast(png_structrp, png_ptr),
|
||||
"Potential overflow in png_zalloc()");
|
||||
|
Loading…
x
Reference in New Issue
Block a user