[libpng16] Avoid possible NULL dereference in png_handle_eXIf when benign_errors

are allowed. Avoid leaking the input buffer "eXIf_buf".
This commit is contained in:
Glenn Randers-Pehrson
2017-07-30 19:36:25 -05:00
parent b73c891891
commit 4ab78af90a
3 changed files with 10 additions and 4 deletions

View File

@@ -2021,7 +2021,7 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_eXIf) != 0)
else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -2044,6 +2044,8 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
info_ptr->num_exif = length;
png_set_eXIf(png_ptr, info_ptr, eXIf_buf);
png_free(png_ptr, eXIf_buf);
}
#endif