[libpng16] Reject iCCP chunk after the first, even if the first one is invalid.

This commit is contained in:
Glenn Randers-Pehrson
2012-03-08 10:40:07 -06:00
parent b57c1c9e6e
commit 6038b80277
4 changed files with 13 additions and 5 deletions

View File

@@ -1359,13 +1359,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
return;
}
if (info_ptr != NULL && (info_ptr->valid & (PNG_INFO_iCCP|PNG_INFO_sRGB)))
if ((png_ptr->mode & PNG_HAVE_iCCP) || (info_ptr != NULL &&
(info_ptr->valid & (PNG_INFO_iCCP|PNG_INFO_sRGB))))
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "Duplicate color profile");
return;
}
png_ptr->mode |= PNG_HAVE_iCCP;
png_free(png_ptr, png_ptr->chunkdata);
/* TODO: read the chunk in pieces, validating it as we go. */
png_ptr->chunkdata = png_voidcast(png_charp, png_malloc(png_ptr, length));