From 60a7506744a296ff1a42c41fc952f7ae8b875b4b Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Wed, 18 Feb 2015 12:24:46 -0600 Subject: [PATCH] [libpng16]Allow calling png_get_IHDR() with NULL arguments (Reuben Hawkins). --- ANNOUNCE | 1 + CHANGES | 1 + libpng-manual.txt | 16 ++++++++-------- libpng.3 | 24 ++++++++++++------------ pngget.c | 22 ++++++++++++++-------- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index db352034f..4b570831d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -53,6 +53,7 @@ Version 1.6.17beta03 [February 17, 2015] Version 1.6.17beta04 [February 18, 2015] Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. + Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 663564517..4fd01ab5c 100644 --- a/CHANGES +++ b/CHANGES @@ -5154,6 +5154,7 @@ Version 1.6.17beta03 [February 17, 2015] Version 1.6.17beta04 [February 18, 2015] Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. + Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/libpng-manual.txt b/libpng-manual.txt index f35ae3a8a..af8301c96 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.6.17beta04 - February 17, 2015 + libpng version 1.6.17beta04 - February 18, 2015 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2015 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.17beta04 - February 17, 2015 + libpng versions 0.97, January 1998, through 1.6.17beta04 - February 18, 2015 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2015 Glenn Randers-Pehrson @@ -1265,13 +1265,13 @@ in until png_read_end() has read the chunk data following the image. the PNG datastream is embedded in a MNG-1.0 datastream) - Any or all of interlace_type, compression_type, or - filter_method can be NULL if you are - not interested in their values. + Any of width, height, color_type, bit_depth, + 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 + This is an unsafe situation if these are not png_uint_32 variables. In such situations, the png_get_image_width() and png_get_image_height() functions described below are safer. @@ -5046,7 +5046,7 @@ means of PNG_OPTION_ON); #endif -It's not a good idea to do this if you are using the new "simplified API", +It's not a good idea to do this if you are using the "simplified API", which needs to be able to recognize sRGB profiles conveyed via the iCCP chunk. @@ -5275,7 +5275,7 @@ Other rules can be inferred by inspecting the libpng source. XVI. Y2K Compliance in libpng -February 17, 2015 +February 18, 2015 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. diff --git a/libpng.3 b/libpng.3 index 3f4557970..4a2dc646b 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,4 +1,4 @@ -.TH LIBPNG 3 "February 17, 2015" +.TH LIBPNG 3 "February 18, 2015" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.6.17beta04 .SH SYNOPSIS @@ -504,7 +504,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.6.17beta04 - February 17, 2015 + libpng version 1.6.17beta04 - February 18, 2015 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2015 Glenn Randers-Pehrson @@ -515,7 +515,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.17beta04 - February 17, 2015 + libpng versions 0.97, January 1998, through 1.6.17beta04 - February 18, 2015 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2015 Glenn Randers-Pehrson @@ -1769,13 +1769,13 @@ in until png_read_end() has read the chunk data following the image. the PNG datastream is embedded in a MNG-1.0 datastream) - Any or all of interlace_type, compression_type, or - filter_method can be NULL if you are - not interested in their values. + Any of width, height, color_type, bit_depth, + 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 + This is an unsafe situation if these are not png_uint_32 variables. In such situations, the png_get_image_width() and png_get_image_height() functions described below are safer. @@ -5550,7 +5550,7 @@ means of PNG_OPTION_ON); #endif -It's not a good idea to do this if you are using the new "simplified API", +It's not a good idea to do this if you are using the "simplified API", which needs to be able to recognize sRGB profiles conveyed via the iCCP chunk. @@ -5779,7 +5779,7 @@ Other rules can be inferred by inspecting the libpng source. .SH XVI. Y2K Compliance in libpng -February 17, 2015 +February 18, 2015 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. @@ -6094,7 +6094,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.6.17beta04 - February 17, 2015: +Libpng version 1.6.17beta04 - February 18, 2015: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -6117,7 +6117,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.6.17beta04, February 17, 2015, are +libpng versions 1.2.6, August 15, 2004, through 1.6.17beta04, February 18, 2015, are Copyright (c) 2004,2006-2014 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -6216,7 +6216,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 17, 2015 +February 18, 2015 .\" end of man page diff --git a/pngget.c b/pngget.c index 0f0d264a6..0a47f9784 100644 --- a/pngget.c +++ b/pngget.c @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.17 [(PENDING RELEASE)] + * Copyright (c) 1998-2015 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.) * @@ -799,14 +799,20 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, { png_debug1(1, "in %s retrieval function", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL || width == NULL || - height == NULL || bit_depth == NULL || color_type == NULL) + if (png_ptr == NULL || info_ptr == NULL) return (0); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - *color_type = info_ptr->color_type; + if (width != NULL) + *width = info_ptr->width; + + if (height != NULL) + *height = info_ptr->height; + + if (bit_depth != NULL) + *bit_depth = info_ptr->bit_depth; + + if (color_type != NULL) + *color_type = info_ptr->color_type; if (compression_type != NULL) *compression_type = info_ptr->compression_type;