summaryrefslogtreecommitdiff
path: root/pngrutil.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2015-11-13 22:47:30 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2015-11-13 22:47:30 -0600
commit8738633bd6c282ab0773f670a0cfa70953cedf72 (patch)
tree826a1e20c75bdf51a96c6b6c4c2ae6b062fd3029 /pngrutil.c
parentb257d4a6a1c3a4352dbfb73abb230e4d20465968 (diff)
downloadlibpng-8738633bd6c282ab0773f670a0cfa70953cedf72.tar.gz
[libpng15] Avoid potential pointer overflow in png_handle_iTXt(),
png_handle_zTXt(), png_handle_sPLT(), and png_handle_pCAL() (Bug report by John Regehr).
Diffstat (limited to 'pngrutil.c')
-rw-r--r--pngrutil.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/pngrutil.c b/pngrutil.c
index ba95f64a7..f212bc8f2 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1327,7 +1327,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 (profile >= png_ptr->chunkdata + slength - 1)
+ if (slength < 1 || profile >= png_ptr->chunkdata + slength - 1)
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
@@ -1476,7 +1476,7 @@ 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 (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)
+ if (slength < 2 || entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
@@ -2005,7 +2005,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 (endptr <= buf + 12)
+ if (length < 12 || endptr <= buf + 12)
{
png_warning(png_ptr, "Invalid pCAL data");
png_free(png_ptr, png_ptr->chunkdata);
@@ -2417,7 +2417,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 (text >= png_ptr->chunkdata + slength - 2)
+ if (slength < 2 || text >= png_ptr->chunkdata + slength - 2)
{
png_warning(png_ptr, "Truncated zTXt chunk");
png_free(png_ptr, png_ptr->chunkdata);
@@ -2554,7 +2554,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
* keyword
*/
- if (lang >= png_ptr->chunkdata + slength - 3)
+ if (slength < 3 || lang >= png_ptr->chunkdata + slength - 3)
{
png_warning(png_ptr, "Truncated iTXt chunk");
png_free(png_ptr, png_ptr->chunkdata);