diff --git a/ANNOUNCE b/ANNOUNCE index c7f51fbb7..038f7ea4a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -58,6 +58,12 @@ Version 1.6.3beta05 [May 8, 2013] Added fixitxt and pngdeflate to the built programs and removed warnings from the source code and timepng that are revealed as a result. Fixed fixitxt when the chunk length is more than 65535 (untested, no test case). + Detect wrong libpng versions linked to pngdeflate, which currently + only works with libpng versions that can be made to reliably fail when + the deflate data contains an out-of-window reference. This means only + 1.6 and later. + Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning + message which it is easier to work round than ignore. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index ff162a319..a02553d24 100644 --- a/CHANGES +++ b/CHANGES @@ -4541,6 +4541,12 @@ Version 1.6.3beta05 [May 8, 2013] Added fixitxt and pngdeflate to the built programs and removed warnings from the source code and timepng that are revealed as a result. Fixed fixitxt when the chunk length is more than 65535 (untested, no test case). + Detect wrong libpng versions linked to pngdeflate, which currently + only works with libpng versions that can be made to reliably fail when + the deflate data contains an out-of-window reference. This means only + 1.6 and later. + Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning + message which it is easier to work round than ignore. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/libtests/timepng.c b/contrib/libtests/timepng.c index 523627f38..7c937971c 100644 --- a/contrib/libtests/timepng.c +++ b/contrib/libtests/timepng.c @@ -252,7 +252,7 @@ int main(int argc, char **argv) while (fgets(filename, FILENAME_MAX+1, stdin)) { - int len = strlen(filename); + size_t len = strlen(filename); if (filename[len-1] == '\n') { diff --git a/contrib/tools/pngdeflate.c b/contrib/tools/pngdeflate.c index 087cab79e..39562b3e1 100644 --- a/contrib/tools/pngdeflate.c +++ b/contrib/tools/pngdeflate.c @@ -13,13 +13,47 @@ */ #include #include -#ifdef PNG_READ_SUPPORTED #include #include -#include +/* Define the following to use this program against your installed libpng, + * rather than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#if PNG_LIBPNG_VER < 10600 /* 1.6.0 */ +# error pngdeflate will not work with libpng versions prior to 1.6 +#endif + +#ifdef PNG_READ_SUPPORTED #include +#ifndef PNG_MAXIMUM_INFLATE_WINDOW +# if PNG_LIBPNG_VER != 10600 && PNG_LIBPNG_VER != 10601 && \ + PNG_LIBPNG_VER != 10602 +# error pngdeflate not supported in this libpng version +# endif +#endif + +/* Copied from pngpriv.h */ +#ifdef __cplusplus +# define png_voidcast(type, value) static_cast(value) +# define png_constcast(type, value) const_cast(value) +# define png_aligncast(type, value) \ + static_cast(static_cast(value)) +# define png_aligncastconst(type, value) \ + static_cast(static_cast(value)) +#else +# define png_voidcast(type, value) (value) +# define png_constcast(type, value) ((type)(value)) +# define png_aligncast(type, value) ((void*)(value)) +# define png_aligncastconst(type, value) ((const void*)(value)) +#endif /* __cplusplus */ + static int idat_error = 0; static int verbose = 0; static int errors = 0; @@ -204,8 +238,8 @@ read_png(FILE *fp) { png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr); - row = malloc(rowbytes); - display = malloc(rowbytes); + row = png_voidcast(png_byte*, malloc(rowbytes)); + display = png_voidcast(png_byte*, malloc(rowbytes)); if (row == NULL || display == NULL) png_error(png_ptr, "OOM allocating row buffers"); @@ -524,11 +558,10 @@ fix_one(FILE *fp, FILE *fpIn, IDAT_info *info, png_uint_32 max_IDAT, int strip) { rx(fpIn, info->header + state, 1); wx(fp, info->header + state, 1); - ++state; ++len_IDAT; --len; - if (state == 2) + if (state++ == 1) { /* The zlib stream is used to validate the compressed IDAT * data in the most relaxed way possible. diff --git a/pngrutil.c b/pngrutil.c index ba50d6ecb..34687a0f2 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.2 [April 25, 2013] + * Last changed in libpng 1.6.3 [(PENDING RELEASE)] * Copyright (c) 1998-2013 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.)