mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Use unsigned constants in buffer length comparisons
This commit is contained in:
parent
5b948c3e11
commit
b0c1d88cee
11
pngrutil.c
11
pngrutil.c
@ -1159,7 +1159,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
/* There should be at least one zero (the compression type byte)
|
||||
* following the separator, and we should be on it
|
||||
*/
|
||||
if (slength < 1 || profile >= png_ptr->chunkdata + slength - 1)
|
||||
if (slength < 1U || profile >= png_ptr->chunkdata + slength - 1U)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
@ -1297,7 +1297,8 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
++entry_start;
|
||||
|
||||
/* A sample depth should follow the separator, and we should be on it */
|
||||
if (slength < 2 || entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)
|
||||
if (slength < 2U ||
|
||||
entry_start > (png_bytep)png_ptr->chunkdata + slength - 2U)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
@ -1771,7 +1772,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
/* We need to have at least 12 bytes after the purpose string
|
||||
in order to get the parameter information. */
|
||||
if (slength < 12 || endptr <= buf + 12)
|
||||
if (slength < 12U || endptr - buf <= 12U)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid pCAL data");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
@ -2222,7 +2223,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
/* Empty loop */ ;
|
||||
|
||||
/* zTXt must have some text after the chunkdataword */
|
||||
if (slength < 2 || text >= png_ptr->chunkdata + slength - 2)
|
||||
if (slength < 2U || text >= png_ptr->chunkdata + slength - 2U)
|
||||
{
|
||||
png_warning(png_ptr, "Truncated zTXt chunk");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
@ -2348,7 +2349,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
* keyword
|
||||
*/
|
||||
|
||||
if (slength < 3 || lang >= png_ptr->chunkdata + slength - 3)
|
||||
if (slength < 3U || lang >= png_ptr->chunkdata + slength - 3U)
|
||||
{
|
||||
png_warning(png_ptr, "Truncated iTXt chunk");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user