diff --git a/ChangeLog.txt b/ChangeLog.txt index 5813e5a6a..772935809 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,9 @@ Change log: +Version 1.6.4 (built with libpng-1.2.9rc1 and zlib-1.2.3) + Fixed bug in handling of undocumented -trns_a option (Michal Politowski). + Fixed bug with "nosave" handling of unknown chunks. + Version 1.6.3 (built with libpng-1.2.9beta11 and zlib-1.2.3) Fixed documentation of iTXt input (Shlomi Tal). diff --git a/png.c b/png.c index 9fc333da5..8b5db963d 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.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -13,7 +13,7 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_9beta11 Your_png_h_is_not_version_1_2_9beta11; +typedef version_1_2_11beta4 Your_png_h_is_not_version_1_2_11beta4; /* Version information for C files. This had better match the version * string defined in png.h. */ @@ -693,7 +693,7 @@ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.9beta11 - March 22, 2006\n\ + return ((png_charp) "\n libpng version 1.2.11beta4 - June 7, 2006\n\ Copyright (c) 1998-2006 Glenn Randers-Pehrson\n\ Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); diff --git a/png.h b/png.h index 11417fff3..2e4fac8e7 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.2.9beta11 - March 22, 2006 + * libpng version 1.2.11beta4 - June 7, 2006 * Copyright (c) 1998-2006 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.) @@ -9,7 +9,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.2.9beta11 - March 22, 2006: Glenn + * libpng versions 0.97, January 1998, through 1.2.11beta4 - June 7, 2006: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -114,6 +114,12 @@ * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] + * 1.2.9rc1 13 10209 12.so.0.9[.0] + * 1.2.9 13 10209 12.so.0.9[.0] + * 1.2.10beta1-8 13 10210 12.so.0.10[.0] + * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10 13 10210 12.so.0.10[.0] + * 1.2.11beta1-4 13 10211 12.so.0.11[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -143,7 +149,7 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.2.6, August 15, 2004, through 1.2.9beta11, March 22, 2006, are + * libpng versions 1.2.6, August 15, 2004, through 1.2.11beta4, June 7, 2006, are * Copyright (c) 2004, 2006 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: @@ -255,13 +261,13 @@ * Y2K compliance in libpng: * ========================= * - * March 22, 2006 + * June 7, 2006 * * 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.2.9beta11 are Y2K compliant. It is my belief that earlier + * upward through 1.2.11beta4 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 @@ -317,9 +323,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.9beta11" +#define PNG_LIBPNG_VER_STRING "1.2.11beta4" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.9beta11 - March 22, 2006 (header)\n" + " libpng version 1.2.11beta4 - June 7, 2006 (header)\n" #define PNG_LIBPNG_VER_SONUM 0 #define PNG_LIBPNG_VER_DLLNUM 13 @@ -327,11 +333,11 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 9 +#define PNG_LIBPNG_VER_RELEASE 11 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ -#define PNG_LIBPNG_VER_BUILD 11 +#define PNG_LIBPNG_VER_BUILD 4 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -355,7 +361,7 @@ * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * 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 10209 /* 1.2.9 */ +#define PNG_LIBPNG_VER 10211 /* 1.2.11 */ #ifndef PNG_VERSION_INFO_ONLY /* include the compression library's header */ @@ -458,7 +464,7 @@ PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +#ifdef PNG_USE_PNGGCCRD PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; #endif /* This isn't currently used. If you need it, see png.c for more details. @@ -1361,7 +1367,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_2_9beta11; +typedef png_structp version_1_2_11beta4; typedef png_struct FAR * FAR * png_structpp; @@ -2644,7 +2650,7 @@ extern PNG_EXPORT(void,png_save_uint_16) #define PNG_HAVE_IHDR 0x01 #define PNG_HAVE_PLTE 0x02 #define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 +#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ #define PNG_HAVE_IEND 0x10 #define PNG_HAVE_gAMA 0x20 #define PNG_HAVE_cHRM 0x40 @@ -2654,6 +2660,7 @@ extern PNG_EXPORT(void,png_save_uint_16) #define PNG_WROTE_INFO_BEFORE_PLTE 0x400 #define PNG_BACKGROUND_IS_GRAY 0x800 #define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ /* flags for the transformations the PNG library does on the image data */ #define PNG_BGR 0x0001 diff --git a/pngconf.h b/pngconf.h index 4141f7b8c..9733a8edd 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.2.9beta11 - March 22, 2006 + * libpng version 1.2.11beta4 - June 7, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2005 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -25,14 +25,19 @@ * PNG_USER_CONFIG has to be defined on the compiler command line. This * includes the resource compiler for Windows DLL configurations. */ - #ifdef PNG_USER_CONFIG +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD +# endif #include "pngusr.h" #endif +/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ +#ifdef PNG_CONFIGURE_LIBPNG #ifdef HAVE_CONFIG_H #include "config.h" #endif +#endif /* * Added at libpng-1.2.8 @@ -62,8 +67,8 @@ #endif #ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated. Use\ - PNG_USER_PRIVATEBUILD instead.") +# pragma message("PRIVATEBUILD is deprecated.\ + Use PNG_USER_PRIVATEBUILD instead.") # define PNG_USER_PRIVATEBUILD PRIVATEBUILD #endif #endif /* __STDC__ */ @@ -728,7 +733,7 @@ # define PNG_MMX_CODE_SUPPORTED # endif # if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \ - defined(__MMX__) + !defined(PNG_USE_PNGVCRD) && defined(__MMX__) # define PNG_USE_PNGGCCRD # endif #endif diff --git a/pngcrush.c b/pngcrush.c index 1548d33fe..906b9f0ee 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -26,7 +26,7 @@ * */ -#define PNGCRUSH_VERSION "1.6.3" +#define PNGCRUSH_VERSION "1.6.4" /* #define PNGCRUSH_COUNT_COLORS @@ -128,10 +128,12 @@ #define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} #define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#if 0 PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +#endif #define PNG_FLAG_CRC_CRITICAL_USE 0x0400 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 @@ -1884,6 +1886,7 @@ int main(int argc, char *argv[]) else if (!strncmp(argv[i], "-trns_a", 7) || !strncmp(argv[i], "-tRNS_a", 7)) { num_trans_in = (png_uint_16) atoi(argv[++i]); + trns_index=num_trans_in-1; have_trns = 1; for (ia = 0; ia < num_trans_in; ia++) trans_in[ia] = (png_byte) atoi(argv[++i]); @@ -1994,7 +1997,7 @@ int main(int argc, char *argv[]) } for (ia = 0; ia < 256; ia++) - trans_in[ia] = trns_array[ia] = 255; + trns_array[ia]=255; for (;;) /* loop on input files */ { @@ -3505,17 +3508,19 @@ int main(int argc, char *argv[]) read_info_ptr, &unknowns); P1("Found %d unknown chunks\n", num_unknowns); - if (num_unknowns) { + if (nosave == 0 && num_unknowns) { png_unknown_chunkp unknowns_keep; /* allocated by us */ int num_unknowns_keep; int i; unknowns_keep = png_malloc(write_ptr, (png_uint_32) num_unknowns*sizeof(png_unknown_chunk)); + P1("malloc for %d unknown chunks\n", num_unknowns); num_unknowns_keep = 0; /* make an array of only those chunks we want to keep */ for (i = 0; i < num_unknowns; i++) { + P1("Handling unknown chunk %d\n", i); /* not EBCDIC-safe, but neither is keep_chunks(): */ P2(" unknown[%d] = %s (%lu bytes, location %d)\n", i, unknowns[i].name, @@ -3551,6 +3556,7 @@ int main(int argc, char *argv[]) png_free(write_ptr, unknowns_keep); } } + P0("unknown chunk handling done.\n"); #endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */ } /* GRR added for quick %-navigation (1) */ diff --git a/pngerror.c b/pngerror.c index f97a759a7..ad6ae0e82 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pnggccrd.c b/pnggccrd.c index bc19f9a73..8dc9c537e 100644 --- a/pnggccrd.c +++ b/pnggccrd.c @@ -7,7 +7,7 @@ * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm * for Intel's performance analysis of the MMX vs. non-MMX code. * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * Copyright (c) 1998, Intel Corporation diff --git a/pngget.c b/pngget.c index b3339e8fa..df7658587 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.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngmem.c b/pngmem.c index c01c67d87..cfe3e0fde 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngpread.c b/pngpread.c index 4a98a2e24..f585239d3 100644 --- a/pngpread.c +++ b/pngpread.c @@ -214,6 +214,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } + if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + if(png_ptr->mode & PNG_AFTER_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) @@ -281,8 +285,9 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) if (png_ptr->mode & PNG_HAVE_IDAT) { - if (png_ptr->push_length == 0) - return; + if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) + if (png_ptr->push_length == 0) + return; if (png_ptr->mode & PNG_AFTER_IDAT) png_error(png_ptr, "Too many IDAT's found"); diff --git a/pngread.c b/pngread.c index e37c21592..9dd83bc7b 100644 --- a/pngread.c +++ b/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -413,6 +413,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. */ + if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + if(png_ptr->mode & PNG_AFTER_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) @@ -985,11 +989,9 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) { if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); } - else - png_ptr->mode |= PNG_AFTER_IDAT; png_handle_unknown(png_ptr, info_ptr, length); if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; @@ -1000,7 +1002,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. */ - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); png_crc_finish(png_ptr, length); } diff --git a/pngrio.c b/pngrio.c index 895ae8899..ce05cada7 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngrtran.c b/pngrtran.c index 0be263981..8b580807c 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngrutil.c b/pngrutil.c index 814a99492..2bde4b416 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.11 June 4, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -829,7 +829,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif #if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) { if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || @@ -840,7 +840,6 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) { - png_warning(png_ptr, "Ignoring incorrect cHRM value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO diff --git a/pngset.c b/pngset.c index ddc45b961..9e499c9bc 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.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngtest.c b/pngtest.c index ac7336b67..00afcd734 100644 --- a/pngtest.c +++ b/pngtest.c @@ -44,7 +44,6 @@ #else # include # include -# include # define READFILE(file, data, length, check) \ check=(png_size_t)fread(data,(png_size_t)1,length,file) # define WRITEFILE(file, data, length, check) \ @@ -538,7 +537,6 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) png_memset(pinfo->pointer, 0xdd, pinfo->size); if(verbose) printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer); - assert(pinfo->size != 12345678); return (png_voidp)(pinfo->pointer); } } @@ -1551,4 +1549,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_9beta11 your_png_h_is_not_version_1_2_9beta11; +typedef version_1_2_11beta4 your_png_h_is_not_version_1_2_11beta4; diff --git a/pngtrans.c b/pngtrans.c index e19b6a0f4..9c4d67cd0 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwrite.c b/pngwrite.c index 720cdb93f..95984f6e5 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwtran.c b/pngwtran.c index 26bd4691a..0372fe656 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.9 April 14, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwutil.c b/pngwutil.c index f9cfdc75e..4a9c52b93 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.9 March 22, 2006 + * Last changed in libpng 1.2.11 June 4, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1567,39 +1567,41 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, /* write the sCAL chunk */ #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width,double height) +png_write_sCAL(png_structp png_ptr, int unit, double width, double height) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_sCAL; #endif + char buf[64]; png_size_t total_len; - char wbuf[32], hbuf[32]; - png_byte bunit = (png_byte)unit; png_debug(1, "in png_write_sCAL\n"); + buf[0] = (char)unit; #if defined(_WIN32_WCE) /* sprintf() function is not supported on WindowsCE */ { wchar_t wc_buf[32]; + size_t wc_len; swprintf(wc_buf, TEXT("%12.12e"), width); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL); + wc_len = wcslen(wc_buf); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); + total_len = wc_len + 2; swprintf(wc_buf, TEXT("%12.12e"), height); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL); + wc_len = wcslen(wc_buf); + WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, + NULL, NULL); + total_len += wc_len; } #else - sprintf(wbuf, "%12.12e", width); - sprintf(hbuf, "%12.12e", height); + sprintf(buf + 1, "%12.12e", width); + total_len = 1 + png_strlen(buf + 1) + 1; + sprintf(buf + total_len, "%12.12e", height); + total_len += png_strlen(buf + total_len); #endif - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - png_debug1(3, "sCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - - png_write_chunk_end(png_ptr); + png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); } #else #ifdef PNG_FIXED_POINT_SUPPORTED @@ -1610,23 +1612,26 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, #ifdef PNG_USE_LOCAL_ARRAYS PNG_sCAL; #endif - png_size_t total_len; - char wbuf[32], hbuf[32]; - png_byte bunit = unit; + png_byte buf[64]; + png_size_t wlen, hlen, total_len; png_debug(1, "in png_write_sCAL_s\n"); - png_strcpy(wbuf,(const char *)width); - png_strcpy(hbuf,(const char *)height); - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); + wlen = png_strlen(width); + hlen = png_strlen(height); + total_len = wlen + hlen + 2; + if (total_len > 64) + { + png_warning(png_ptr, "Can't write sCAL (buffer too small)"); + return; + } - png_debug1(3, "sCAL total length = %d\n", total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); + buf[0] = (png_byte)unit; + png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ + png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ - png_write_chunk_end(png_ptr); + png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); } #endif #endif