mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Check validity of "num_unknowns" parameter
of png_set_unknown_chunks().
This commit is contained in:
13
pngset.c
13
pngset.c
@@ -1039,9 +1039,16 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
|
||||
return;
|
||||
|
||||
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
png_sizeof(png_unknown_chunk));
|
||||
if (num_unknowns < 0 ||
|
||||
num_unknowns >= UINT_MAX-info_ptr->unknown_chunks_num ||
|
||||
num_unknowns >= PNG_SIZE_MAX/png_sizeof(png_unknown_chunk)
|
||||
- info_ptr->unknown_chunks_num)
|
||||
np=NULL;
|
||||
|
||||
else
|
||||
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
png_sizeof(png_unknown_chunk));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user