From 173432da9eb67ca5cdf80e64eda1492afaa2190d Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 30 Jan 2015 10:24:58 -0600 Subject: [PATCH] [lbpng14] Quieted some harmless warnings from Coverity-scan. --- ANNOUNCE | 21 ++++++----- CHANGES | 3 ++ png.c | 6 ++-- png.h | 102 +++++++++++++++++++++++++++++++++------------------- pngconf.h | 103 +++++++++++++++++++++++++++++++++++++++-------------- pngpriv.h | 18 ++++++---- pngrtran.c | 46 ++++++++++++++++-------- pngset.c | 6 ++-- pngwrite.c | 12 +++---- pngwutil.c | 6 ++-- 10 files changed, 215 insertions(+), 108 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 96b2a9522..5ebad4bcf 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.4.15beta01 - January 27, 2015 +Libpng 1.4.15beta02 - January 30, 2015 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. @@ -9,21 +9,21 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - 1.4.15beta01.tar.xz (LZMA-compressed, recommended) - 1.4.15beta01.tar.gz - 1.4.15beta01.tar.bz2 + 1.4.15beta02.tar.xz (LZMA-compressed, recommended) + 1.4.15beta02.tar.gz + 1.4.15beta02.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp1415b01.7z (LZMA-compressed, recommended) - lp1415b01.zip + lp1415b02.7z (LZMA-compressed, recommended) + lp1415b02.zip Other information: - 1.4.15beta01-README.txt - 1.4.15beta01-LICENSE.txt - libpng-1.4.15beta01-*.asc (armored detached GPG signatures) + 1.4.15beta02-README.txt + 1.4.15beta02-LICENSE.txt + libpng-1.4.15beta02-*.asc (armored detached GPG signatures) Changes since the last public release (1.4.14): @@ -31,6 +31,9 @@ version 1.4.15beta01 [January 27, 2015] Restored test for maximum allowed image width that was removed from libpng-1.4.13 (fixes CVE-2014-9495 and CVE-2015-0973). +version 1.4.15beta02 [January 30, 2015] + Quieted some harmless warnings from Coverity-scan. + Send comments/corrections/commendations to glennrp at users.sourceforge.net or to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement). diff --git a/CHANGES b/CHANGES index f37bc901e..562220e95 100644 --- a/CHANGES +++ b/CHANGES @@ -2926,6 +2926,9 @@ version 1.4.15beta01 [January 27, 2015] Restored test for maximum allowed image width that was removed from libpng-1.4.13 (fixes CVE-2014-9495 and CVE-2015-0973). +version 1.4.15beta02 [January 30, 2015] + Quieted some harmless warnings from Coverity-scan. + Send comments/corrections/commendations to glennrp at users.sourceforge.net or to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement). diff --git a/png.c b/png.c index 507c59fdf..4204d8d63 100644 --- a/png.c +++ b/png.c @@ -17,7 +17,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_4_15beta01 Your_png_h_is_not_version_1_4_15beta01; +typedef version_1_4_15beta02 Your_png_h_is_not_version_1_4_15beta02; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -547,13 +547,13 @@ png_get_copyright(png_const_structp png_ptr) #else #ifdef __STDC__ return ((png_charp) PNG_STRING_NEWLINE \ - "libpng version 1.4.15beta01 - January 27, 2015" PNG_STRING_NEWLINE \ + "libpng version 1.4.15beta02 - January 30, 2015" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE); #else - return ((png_charp) "libpng version 1.4.15beta01 - January 27, 2015\ + return ((png_charp) "libpng version 1.4.15beta02 - January 30, 2015\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); diff --git a/png.h b/png.h index 4370e0869..0b7b28928 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.4.15beta01 - January 27, 2015 + * libpng version %VER% - %DATE% * Copyright (c) 1998-2011 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.) @@ -11,7 +11,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.4.15beta01 - January 27, 2015: Glenn + * libpng versions 0.97, January 1998, through %VER% - %DATE%: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -176,7 +176,7 @@ * 1.4.14beta01 14 10414 14.so.14.14[.0] * 1.4.14rc01-02 14 10414 14.so.14.14[.0] * 1.4.14 14 10414 14.so.14.14[.0] - * 1.4.15beta01 14 10415 14.so.14.15[.0] + * 1.4.15beta01-02 14 10415 14.so.14.15[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -208,7 +208,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.4.15beta01, January 27, 2015, are + * libpng versions 1.2.6, August 15, 2004, through %VER%, %DATE%, are * Copyright (c) 2004, 2006-2013 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: @@ -320,13 +320,13 @@ * Y2K compliance in libpng: * ========================= * - * January 27, 2015 + * %DATE% * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.4.15beta01 are Y2K compliant. It is my belief that earlier + * upward through %VER% are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -382,22 +382,22 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.4.15beta01" +#define PNG_LIBPNG_VER_STRING "%VER%" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.4.15beta01 - January 27, 2015\n" + " libpng version %VER% - %DATE%\n" -#define PNG_LIBPNG_VER_SONUM 14 -#define PNG_LIBPNG_VER_DLLNUM 14 +#define PNG_LIBPNG_VER_SONUM %SONUM% +#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 4 -#define PNG_LIBPNG_VER_RELEASE 15 +#define PNG_LIBPNG_VER_MAJOR %MAJOR% +#define PNG_LIBPNG_VER_MINOR %MINOR% +#define PNG_LIBPNG_VER_RELEASE %RELEASE% /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ -#define PNG_LIBPNG_VER_BUILD 01 +#define PNG_LIBPNG_VER_BUILD %BUILDNUM% /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -414,7 +414,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA +#define PNG_LIBPNG_BUILD_BASE_TYPE %BUILDTYPE% /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. @@ -422,7 +422,7 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10415 /* 1.4.15 */ +#define PNG_LIBPNG_VER %VER_NUM% /* %MAJOR%.%MINOR%.%RELEASE% */ #ifndef PNG_VERSION_INFO_ONLY /* Include the compression library's header */ @@ -765,8 +765,9 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) * single color specified that should be treated as fully transparent. * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. */ - png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for paletted - image */ +%12-% png_bytep trans PNG_DEPSTRUCT; /* alpha values for paletted image */ +%14+% png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for paletted +%14+% image */ png_color_16 trans_color PNG_DEPSTRUCT; /* transparent color for non-palette image */ #endif @@ -858,8 +859,10 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) #endif /* New members added in libpng-1.0.6 */ +%12-%#ifdef PNG_FREE_ME_SUPPORTED png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is responsible for freeing */ +%12-%#endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) @@ -1069,6 +1072,7 @@ typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ +%12-% defined(PNG_LEGACY_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, png_row_infop, png_bytep)); @@ -1202,7 +1206,8 @@ struct png_struct_def * We will change the typedef from png_size_t to png_alloc_size_t * in libpng-1.6.0 */ - png_alloc_size_t user_chunk_malloc_max PNG_DEPSTRUCT; +%12-% png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT; +%14+% png_alloc_size_t user_chunk_malloc_max PNG_DEPSTRUCT; #endif png_uint_32 iwidth PNG_DEPSTRUCT; /* width of current interlaced row in pixels */ @@ -1248,8 +1253,13 @@ struct png_struct_def start of file */ #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +%12-%#ifdef PNG_LEGACY_SUPPORTED +%12-% png_byte filler PNG_DEPSTRUCT; /* filler byte for pixel +%12-% expansion */ +%12-%#else png_uint_16 filler PNG_DEPSTRUCT; /* filler bytes for pixel expansion */ +%12-%#endif #endif #ifdef PNG_bKGD_SUPPORTED @@ -1308,7 +1318,9 @@ struct png_struct_def #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for +%12-% png_bytep trans PNG_DEPSTRUCT; /* alpha values for paletted +%12-% files */ +%14+% png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for paletted files */ png_color_16 trans_color PNG_DEPSTRUCT; /* transparent color for non-paletted files */ @@ -1405,8 +1417,10 @@ struct png_struct_def /* New members added in libpng-1.0.6 */ +%12-%#ifdef PNG_FREE_ME_SUPPORTED png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is responsible for freeing */ +%12-%#endif #ifdef PNG_USER_CHUNKS_SUPPORTED png_voidp user_chunk_ptr PNG_DEPSTRUCT; @@ -1446,6 +1460,11 @@ struct png_struct_def png_byte filter_type PNG_DEPSTRUCT; #endif +%12-%/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ +%12-%#if (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) +%12-% png_uint_32 row_buf_size PNG_DEPSTRUCT; +%12-%#endif +%12-% /* New members added in libpng-1.2.0 */ /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ @@ -1479,10 +1498,10 @@ struct png_struct_def #ifdef PNG_USER_LIMITS_SUPPORTED png_uint_32 user_width_max PNG_DEPSTRUCT; png_uint_32 user_height_max PNG_DEPSTRUCT; - /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown - * chunks that can be stored (0 means unlimited). - */ - png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT; +%14+% /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown +%14+% * chunks that can be stored (0 means unlimited). +%14+% */ +%14+% png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT; #endif /* New member added in libpng-1.0.25 and 1.2.17 */ @@ -1508,7 +1527,7 @@ struct png_struct_def /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef png_structp version_1_4_15beta01; +typedef png_structp version_%_VER_%; typedef png_struct FAR * FAR * png_structpp; @@ -1535,11 +1554,11 @@ PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, png_size_t num_to_check)); -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -#define png_check_sig(sig,n) !png_sig_cmp((sig), 0, (n)) - +%14+%/* Simple signature checking function. This is the same as calling +%14+% * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). +%14+% */ +%14+%#define png_check_sig(sig,n) !png_sig_cmp((sig), 0, (n)) +%14+% /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORT(png_structp,png_create_read_struct) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, @@ -2031,17 +2050,22 @@ PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_const_structp png_ptr)); #endif -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +%12-%#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ +%12-% defined(PNG_LEGACY_SUPPORTED) +%14+%#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +%12-%#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ +%12-% defined(PNG_LEGACY_SUPPORTED) +%14+%#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ +%12-% defined(PNG_LEGACY_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, @@ -2084,9 +2108,9 @@ PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, png_alloc_size_t size)) PNG_ALLOCATED; -/* Added at libpng version 1.4.0 */ -PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr, - png_alloc_size_t size)) PNG_ALLOCATED; +%14+%/* Added at libpng version 1.4.0 */ +%14+%PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr, +%14+% png_alloc_size_t size)) PNG_ALLOCATED; /* Added at libpng version 1.2.4 */ PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, @@ -2098,10 +2122,12 @@ PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); +%12-%#ifdef PNG_FREE_ME_SUPPORTED /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application */ PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)); +%12-%#endif /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 @@ -2455,13 +2481,15 @@ PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_const_structp png_ptr, - png_infop info_ptr, png_bytep *trans_alpha, int *num_trans, +%12-% png_infop info_ptr, png_bytep *trans, int *num_trans, +%14+% png_infop info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans_alpha, int num_trans, +%12-% png_infop info_ptr, png_bytep trans, int num_trans, +%14+% png_infop info_ptr, png_bytep trans_alpha, int num_trans, png_color_16p trans_color)); #endif diff --git a/pngconf.h b/pngconf.h index bcadf7e1b..cf63bd186 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.4.15beta01 - January 27, 2015 + * libpng version %VER% - %DATE% * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -59,7 +59,7 @@ * distinguish your DLL from those of the official release. These * correspond to the trailing letters that come after the version * number and must match your private DLL name> - * e.g. // private DLL "libpng14gx.dll" + * e.g. // private DLL "libpng%NN%gx.dll" * #define PNG_USER_DLLFNAME_POSTFIX "gx" * * The following macros are also at your disposal if you want to complete the @@ -352,7 +352,8 @@ #endif /* Enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) +%12-%#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +%14+%#if !defined(MACOS) && !defined(RISCOS) # include #endif @@ -499,12 +500,46 @@ * 1.4.0) */ +%12-%/* The following support, added after version 1.0.0, can be turned off +%12-% * here en masse by defining PNG_LEGACY_SUPPORTED in case you need binary +%12-% * compatibility with old applications that require the length of +%12-% * png_struct and png_info to remain unchanged. +%12-% */ +%12-% +%12-%#ifdef PNG_LEGACY_SUPPORTED +%12-%# define PNG_NO_FREE_ME +%12-%# define PNG_NO_READ_UNKNOWN_CHUNKS +%12-%# define PNG_NO_WRITE_UNKNOWN_CHUNKS +%12-%# define PNG_NO_HANDLE_AS_UNKNOWN +%12-%# define PNG_NO_READ_USER_CHUNKS +%12-%# define PNG_NO_READ_iCCP +%12-%# define PNG_NO_WRITE_iCCP +%12-%# define PNG_NO_READ_iTXt +%12-%# define PNG_NO_WRITE_iTXt +%12-%# define PNG_NO_READ_sCAL +%12-%# define PNG_NO_WRITE_sCAL +%12-%# define PNG_NO_READ_sPLT +%12-%# define PNG_NO_WRITE_sPLT +%12-%# define PNG_NO_INFO_IMAGE +%12-%# define PNG_NO_READ_RGB_TO_GRAY +%12-%# define PNG_NO_READ_USER_TRANSFORM +%12-%# define PNG_NO_WRITE_USER_TRANSFORM +%12-%# define PNG_NO_USER_MEM +%12-%# define PNG_NO_READ_EMPTY_PLTE +%12-%# define PNG_NO_MNG_FEATURES +%12-%# define PNG_NO_FIXED_POINT_SUPPORTED +%12-%#endif +%12-% /* Ignore attempt to turn off both floating and fixed point support */ #if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ !defined(PNG_NO_FIXED_POINT_SUPPORTED) # define PNG_FIXED_POINT_SUPPORTED #endif +%12-%#ifndef PNG_NO_FREE_ME +%12-%# define PNG_FREE_ME_SUPPORTED +%12-%#endif +%12-% #ifdef PNG_READ_SUPPORTED /* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */ @@ -672,7 +707,10 @@ #endif /* PNG_WRITE_SUPPORTED */ -#define PNG_NO_ERROR_NUMBERS +%14+%#define PNG_NO_ERROR_NUMBERS +%12-%#ifndef PNG_NO_ERROR_NUMBERS +%12-%# define PNG_ERROR_NUMBERS_SUPPORTED +%12-%#endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) @@ -754,23 +792,23 @@ # define PNG_USER_CHUNK_MALLOC_MAX 0 #endif -/* Added at libpng-1.4.0 */ -#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED) -# define PNG_IO_STATE_SUPPORTED -#endif - -#ifndef PNG_LITERAL_SHARP -# define PNG_LITERAL_SHARP 0x23 -#endif -#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET -# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b -#endif -#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET -# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d -#endif -#ifndef PNG_STRING_NEWLINE -#define PNG_STRING_NEWLINE "\n" -#endif +%14+%/* Added at libpng-1.4.0 */ +%14+%#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED) +%14+%# define PNG_IO_STATE_SUPPORTED +%14+%#endif +%14+% +%14+%#ifndef PNG_LITERAL_SHARP +%14+%# define PNG_LITERAL_SHARP 0x23 +%14+%#endif +%14+%#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET +%14+%# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b +%14+%#endif +%14+%#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET +%14+%# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d +%14+%#endif +%14+%#ifndef PNG_STRING_NEWLINE +%14+%#define PNG_STRING_NEWLINE "\n" +%14+%#endif /* These are currently experimental features, define them if you want */ @@ -791,9 +829,9 @@ #endif */ -#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) -# define PNG_USE_READ_MACROS -#endif +%14+%#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +%14+%# define PNG_USE_READ_MACROS +%14+%#endif /* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING */ @@ -802,6 +840,13 @@ # define PNG_POINTER_INDEXING_SUPPORTED #endif +%12-%/* These functions are turned off by default, as they will be phased +%12-% * out. +%12-% */ +%12-%/* +%12-%#define PNG_USELESS_TESTS_SUPPORTED +%12-%#define PNG_CORRECT_PALETTE_SUPPORTED +%12-%*/ /* Any chunks you are not interested in, you can undef here. The * ones that allocate memory may be expecially important (hIST, @@ -1139,7 +1184,8 @@ typedef unsigned char png_byte; #define png_sizeof(x) (sizeof (x)) /* The following is needed for medium model support. It cannot be in the - * pngpriv.h header. Needs modification for other compilers besides +%12-% * PNG_INTERNAL section. Needs modification for other compilers besides +%14+% * pngpriv.h header. Needs modification for other compilers besides * MSC. Model independent support declares all arrays and pointers to be * large using the far keyword. The zlib version used must also support * model independent data. As of version zlib 1.0.4, the necessary changes @@ -1214,7 +1260,11 @@ typedef char FAR * png_charp; typedef png_fixed_point FAR * png_fixed_point_p; #ifndef PNG_NO_STDIO +%12-%# ifdef _WIN32_WCE +%12-%typedef HANDLE png_FILE_p; +%12-%# else typedef FILE * png_FILE_p; +%12-%# endif #endif #ifdef PNG_FLOATING_POINT_SUPPORTED @@ -1370,7 +1420,8 @@ typedef char FAR * FAR * FAR * png_charppp; * Added at libpng-1.2.41. */ -#ifndef PNG_NO_PEDANTIC_WARNINGS +%12-%#ifdef PNG_PEDANTIC_WARNINGS +%14+%#ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif diff --git a/pngpriv.h b/pngpriv.h index e46d725bc..3ac6b1531 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -1,7 +1,7 @@ /* pngpriv.h - private declarations for use inside libpng * - * libpng version 1.4.15beta01 - January 27, 2015 + * libpng version %VER% - %DATE% * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2014 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -163,9 +163,12 @@ #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 - /* 0x1000 unused */ - /* 0x2000 unused */ - /* 0x4000 unused */ +%14+% /* 0x1000 unused */ +%14+% /* 0x2000 unused */ +%14+% /* 0x4000 unused */ +%12-%#define PNG_FLAG_FREE_PLTE 0x1000 +%12-%#define PNG_FLAG_FREE_TRNS 0x2000 +%12-%#define PNG_FLAG_FREE_HIST 0x4000 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L #define PNG_FLAG_LIBRARY_MISMATCH 0x20000L @@ -625,14 +628,14 @@ PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, #ifdef PNG_READ_BACKGROUND_SUPPORTED #ifdef PNG_READ_GAMMA_SUPPORTED PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_color, png_color_16p background, + png_color_16p %TV%, png_color_16p background, png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift)); #else PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_color, png_color_16p background)); + png_color_16p %TV%, png_color_16p background)); #endif #endif @@ -825,7 +828,8 @@ PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, #ifdef PNG_cHRM_SUPPORTED #ifdef PNG_CHECK_cHRM_SUPPORTED -/* Added at libpng version 1.2.34 and 1.4.0 */ +%12-%/* Added at libpng version 1.2.34 */ +%14+%/* Added at libpng version 1.2.34 and 1.4.0 */ PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2, unsigned long *hi_product, unsigned long *lo_product)); #endif diff --git a/pngrtran.c b/pngrtran.c index 576eddf18..8d9d98186 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.4.13 [February 6, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.4.15 [%RDATE%] + * 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.) * @@ -2370,10 +2370,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, w; + png_byte hi,lo; - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + hi=*(sp)++; lo=*(sp)++; + red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + blue = (png_uint_16)((hi << 8) | (lo)); if (red == green && red == blue) w = red; @@ -2405,10 +2409,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, gray16; + png_byte hi,lo; - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + hi=*(sp)++; lo=*(sp)++; + red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + blue = (png_uint_16)((hi << 8) | (lo)); if (red != green || red != blue) rgb_error |= 1; @@ -2468,10 +2476,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, w; + png_byte hi,lo; - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + hi=*(sp)++; lo=*(sp)++; + red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + blue = (png_uint_16)((hi << 8) | (lo)); if (red == green && red == blue) w = red; @@ -2505,9 +2517,15 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + png_byte hi,lo; + + hi=*(sp)++; lo=*(sp)++; + red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; + blue = (png_uint_16)((hi << 8) | (lo)); + if (red != green || red != blue) rgb_error |= 1; gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); diff --git a/pngset.c b/pngset.c index 8a85913bc..e4edea59c 100644 --- a/pngset.c +++ b/pngset.c @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.4.13 [February 6, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.4.15 [%RDATE%] + * 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.) * @@ -150,7 +150,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point if (png_ptr == NULL || info_ptr == NULL) return; - if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX) + if (int_gamma >= (png_fixed_point)PNG_UINT_31_MAX) { png_warning(png_ptr, "Limiting gamma to 21474.83"); png_gamma=PNG_UINT_31_MAX; diff --git a/pngwrite.c b/pngwrite.c index 26a8f56d4..8f1e1b2a5 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.4.14 [November 20, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.4.15 [%RDATE%] + * 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.) * @@ -1063,14 +1063,13 @@ png_set_filter(png_structp png_ptr, int method, int filters) { switch (filters & (PNG_ALL_FILTERS | 0x07)) { + case PNG_FILTER_VALUE_NONE: + png_ptr->do_filter = PNG_FILTER_NONE; break; #ifdef PNG_WRITE_FILTER_SUPPORTED case 5: case 6: case 7: png_warning(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_WRITE_FILTER_SUPPORTED */ - case PNG_FILTER_VALUE_NONE: - png_ptr->do_filter = PNG_FILTER_NONE; break; -#ifdef PNG_WRITE_FILTER_SUPPORTED + break; case PNG_FILTER_VALUE_SUB: png_ptr->do_filter = PNG_FILTER_SUB; break; case PNG_FILTER_VALUE_UP: @@ -1082,6 +1081,7 @@ png_set_filter(png_structp png_ptr, int method, int filters) default: png_ptr->do_filter = (png_byte)filters; break; #else default: png_warning(png_ptr, "Unknown row filter for method 0"); + break; #endif /* PNG_WRITE_FILTER_SUPPORTED */ } diff --git a/pngwutil.c b/pngwutil.c index 0fd9fc295..812d48e0a 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.4.8 [July 7, 2011] - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Last changed in libpng 1.4.15 [%RDATE%] + * 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.) * @@ -283,7 +283,7 @@ png_text_compress(png_structp png_ptr, old_ptr = comp->output_ptr; comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_alloc_size_t) - (comp->max_output_ptr * png_sizeof(png_charpp))); + (comp->max_output_ptr * png_sizeof(png_charp))); png_memcpy(comp->output_ptr, old_ptr, old_max * png_sizeof(png_charp)); png_free(png_ptr, old_ptr);