[master] Revised png_check_IHDR() again
to check info_ptr members instead of the contents of the returned parameters.
diff --git a/ANNOUNCE b/ANNOUNCE
index 3e0e938..a9e42ee 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
-Libpng 1.2.41beta03 - September 30, 2009
+Libpng 1.2.41beta03 - October 1, 2009
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@@ -51,7 +51,9 @@
version 1.2.41beta02 [September 30, 2009]
Revised png_check_IHDR().
-version 1.2.41beta03 [September 30, 2009]
+version 1.2.41beta03 [October 1, 2009]
+ Revised png_check_IHDR() again, to check info_ptr members instead of
+ the contents of the returned parameters.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
diff --git a/CHANGES b/CHANGES
index 72811bf..e95f871 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2466,7 +2466,7 @@
version 1.2.40rc01 [September 2, 2009]
Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
-version 1.2.40 and 1.0.49 [September 30, 2009]
+version 1.2.40 and 1.0.49 [October 1, 2009]
No changes.
version 1.0.50 [September 10, 2009]
@@ -2481,7 +2481,9 @@
version 1.2.41beta02 [September 30, 2009]
Revised png_check_IHDR().
-version 1.2.41beta03 [September 30, 2009]
+version 1.2.41beta03 [October 1, 2009]
+ Revised png_check_IHDR() again, to check info_ptr members instead of
+ the contents of the returned parameters.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/libpng-1.2.41beta03.txt b/libpng-1.2.41beta03.txt
index 0b1b143..a82d0f7 100644
--- a/libpng-1.2.41beta03.txt
+++ b/libpng-1.2.41beta03.txt
@@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
- libpng version 1.2.41beta03 - September 30, 2009
+ libpng version 1.2.41beta03 - October 1, 2009
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@
Based on:
- libpng versions 0.97, January 1998, through 1.2.41beta03 - September 30, 2009
+ libpng versions 0.97, January 1998, through 1.2.41beta03 - October 1, 2009
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -545,10 +545,33 @@
for PNG 1.0)
interlace_type - (PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7)
- Any or all of interlace_type, compression_type, of
+
+ Any or all of interlace_type, compression_type, or
filter_method can be NULL if you are
not interested in their values.
+ Note that png_get_IHDR() returns 32-bit data into
+ the application's width and height variables.
+ This is an unsafe situation if these are 16-bit
+ variables. In such situations, the
+ png_get_image_width() and png_get_image_height()
+ functions described below are safer.
+
+ width = png_get_image_width(png_ptr,
+ info_ptr);
+ height = png_get_image_height(png_ptr,
+ info_ptr);
+ bit_depth = png_get_bit_depth(png_ptr,
+ info_ptr);
+ color_type = png_get_color_type(png_ptr,
+ info_ptr);
+ filter_method = png_get_filter_type(png_ptr,
+ info_ptr);
+ compression_type = png_get_compression_type(png_ptr,
+ info_ptr);
+ interlace_type = png_get_interlace_type(png_ptr,
+ info_ptr);
+
channels = png_get_channels(png_ptr, info_ptr);
channels - number of channels of info for the
color type (valid values are 1 (GRAY,
@@ -568,23 +591,6 @@
be in signature[4] through signature[7]
(see png_set_sig_bytes())).
-
- width = png_get_image_width(png_ptr,
- info_ptr);
- height = png_get_image_height(png_ptr,
- info_ptr);
- bit_depth = png_get_bit_depth(png_ptr,
- info_ptr);
- color_type = png_get_color_type(png_ptr,
- info_ptr);
- filter_method = png_get_filter_type(png_ptr,
- info_ptr);
- compression_type = png_get_compression_type(png_ptr,
- info_ptr);
- interlace_type = png_get_interlace_type(png_ptr,
- info_ptr);
-
-
These are also important, but their validity depends on whether the chunk
has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
@@ -2982,6 +2988,15 @@
are usually indented the same as the first line of the statement
plus four more spaces.
+For macro definitions we use 2-space indentation, always leaving the "#"
+in the first column.
+
+ #ifndef PNG_NO_FEATURE
+ # ifndef PNG_FEATURE_SUPPORTED
+ # define PNG_FEATURE_SUPPORTED
+ # endif
+ #endif
+
Comments appear with the leading "/*" at the same indentation as
the statement that follows the comment:
@@ -3058,7 +3073,7 @@
XIII. Y2K Compliance in libpng
-September 30, 2009
+October 1, 2009
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
diff --git a/png.c b/png.c
index 60dc2ae..a06fa92 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.2.41 [September 30, 2009]
+ * Last changed in libpng 1.2.41 [October 1, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -705,7 +705,7 @@
png_get_copyright(png_structp png_ptr)
{
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
- return ((png_charp) "\n libpng version 1.2.41beta03 - September 30, 2009\n\
+ return ((png_charp) "\n libpng version 1.2.41beta03 - October 1, 2009\n\
Copyright (c) 1998-2009 Glenn Randers-Pehrson\n\
Copyright (c) 1996-1997 Andreas Dilger\n\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -953,14 +953,6 @@
#endif
{
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
- if ((width >> 16) == height)
- {
- /* This is likely to be caused by passing consecutive addresses
- * of 16-bit width and height variables to png_get_IHDR(), which
- * overflowed when we tried to fill them with 31-bit data.
- */
- png_warning(png_ptr, "High bytes of width == low bytes of height");
- }
error = 1;
}
diff --git a/pngget.c b/pngget.c
index c451104..04e2418 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
- * Last changed in libpng 1.2.41 [September 30, 2009]
+ * Last changed in libpng 1.2.41 [October 1, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -567,10 +567,6 @@
int *color_type, int *interlace_type, int *compression_type,
int *filter_type)
{
- int test_interlace_type = 0;
- int test_compression_type = 0;
- int test_filter_type = 0;
-
png_debug1(1, "in %s retrieval function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
@@ -583,25 +579,22 @@
*color_type = info_ptr->color_type;
if (compression_type != NULL)
- {
*compression_type = info_ptr->compression_type;
- test_compression_type = *compression_type;
- }
if (filter_type != NULL)
- {
*filter_type = info_ptr->filter_type;
- test_filter_type = *filter_type;
- }
if (interlace_type != NULL)
- {
*interlace_type = info_ptr->interlace_type;
- test_interlace_type = *interlace_type;
- }
- png_check_IHDR (png_ptr, *width, *height, *bit_depth, *color_type,
- test_interlace_type, test_compression_type, test_filter_type);
+ /* This is redundant if we can be sure that the info_ptr values were all
+ * assigned in png_set_IHDR(). We do the check anyhow in case an
+ * application has ignored our advice not to mess with the members
+ * of info_ptr directly.
+ */
+ png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
+ info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
+ info_ptr->compression_type, info_ptr->filter_type);
return (1);
}
diff --git a/pngset.c b/pngset.c
index e29c944..bef75cc 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
- * Last changed in libpng 1.2.41 [September 30, 2009]
+ * Last changed in libpng 1.2.41 [October 1, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -233,16 +233,18 @@
if (png_ptr == NULL || info_ptr == NULL)
return;
- png_check_IHDR (png_ptr, width, height, bit_depth, color_type,
- interlace_type, compression_type, filter_type);
-
info_ptr->width = width;
info_ptr->height = height;
info_ptr->bit_depth = (png_byte)bit_depth;
- info_ptr->color_type =(png_byte) color_type;
+ info_ptr->color_type = (png_byte)color_type;
info_ptr->compression_type = (png_byte)compression_type;
info_ptr->filter_type = (png_byte)filter_type;
info_ptr->interlace_type = (png_byte)interlace_type;
+
+ png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
+ info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
+ info_ptr->compression_type, info_ptr->filter_type);
+
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
info_ptr->channels = 1;
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)