mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
PNG_IMAGE_PNG_SIZE_MAX error correction
The macro underreported the size (by up to 512 bytes) of an 8-bit non-color palette based memory format because it failed to take into account that the memory palette has to be expanded to full RGB when it is written to PNG. This is not likely to be a serious bug because the macro is new, the memory format in question is likely to be rarely used and the result of an undersized buffer fails in a safe way. Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
@@ -3209,7 +3209,11 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
||||
{
|
||||
/* This is non-fatal: */
|
||||
if (size > PNG_IMAGE_PNG_SIZE_MAX(image->image))
|
||||
{
|
||||
logerror(image, "memory", ": PNG_IMAGE_SIZE_MAX wrong", "");
|
||||
if ((image->opts & STRICT) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
initimage(output, image->opts, "memory", image->stride_extra);
|
||||
output->input_memory = malloc(size);
|
||||
@@ -3224,7 +3228,12 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
||||
{
|
||||
/* This is also non-fatal (maybe): */
|
||||
if (size != output->input_memory_size)
|
||||
{
|
||||
logerror(image, "memory", ": memory size wrong", "");
|
||||
|
||||
if ((image->opts & STRICT) != 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user