From 8aa1638ccc730eb5645f2d2d67ce9530b8c3e927 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Mon, 26 Sep 2016 08:09:44 -0500 Subject: [PATCH] [libpng16] Add tests/badcrc.png and tests/badadler.png to tests/pngtest. Merged pngtest.c with libpng-1.7.0beta84/pngtest.c --- ANNOUNCE | 7 +++- CHANGES | 5 ++- pngtest.c | 93 +++++++++++++++++++++------------------------ tests/badadler.png | Bin 0 -> 67 bytes tests/badcrc.png | Bin 0 -> 67 bytes tests/pngtest | 2 + 6 files changed, 54 insertions(+), 53 deletions(-) create mode 100644 tests/badadler.png create mode 100644 tests/badcrc.png diff --git a/ANNOUNCE b/ANNOUNCE index 9b5b91fa1..3a72aa278 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -Libpng 1.6.26beta01 - September 25, 2016 +Libpng 1.6.26beta01 - September 26, 2016 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. @@ -25,7 +25,7 @@ Other information: Changes since the last public release (1.6.25): -Version 1.6.26beta01 [September 25, 2016] +Version 1.6.26beta01 [September 26, 2016] Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo, bugfix by John Bowler). Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL @@ -37,6 +37,9 @@ Version 1.6.26beta01 [September 25, 2016] pngrutil.c. If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE, ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs. + Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error(). + Add tests/badcrc.png and tests/badadler.png to tests/pngtest. + Merged pngtest.c with libpng-1.7.0beta84/pngtest.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 225d8a309..e0cf9ec8c 100644 --- a/CHANGES +++ b/CHANGES @@ -5703,7 +5703,7 @@ Version 1.6.25rc05 [August 30, 2016] Version 1.6.25 [September 1, 2016] No changes. -Version 1.6.26beta01 [September 25, 2016] +Version 1.6.26beta01 [September 26, 2016] Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo, bugfix by John Bowler). Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL @@ -5715,6 +5715,9 @@ Version 1.6.26beta01 [September 25, 2016] pngrutil.c. If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE, ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs. + Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error(). + Add tests/badcrc.png and tests/badadler.png to tests/pngtest. + Merged pngtest.c with libpng-1.7.0beta84/pngtest.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngtest.c b/pngtest.c index f1f688b71..c7b8fcfb0 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.6.25 [September 1, 2016] + * Last changed in libpng 1.7.0 [(PENDING RELEASE)] * Copyright (c) 1998-2002,2004,2006-2016 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.) @@ -43,15 +43,6 @@ #include "png.h" -/* 1.6.1 added support for the configure test harness, which uses 77 to indicate - * a skipped test, in earlier versions we need to succeed on a skipped test, so: - */ -#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) -# define SKIP 77 -#else -# define SKIP 0 -#endif - /* Known chunks that exist in pngtest.png must be supported or pngtest will fail * simply as a result of re-ordering them. This may be fixed in 1.7 * @@ -514,10 +505,10 @@ typedef struct memory_information typedef memory_information *memory_infop; static memory_infop pinformation = NULL; -static png_alloc_size_t current_allocation = 0; -static png_alloc_size_t maximum_allocation = 0; -static png_alloc_size_t total_allocation = 0; -static png_alloc_size_t num_allocations = 0; +static int current_allocation = 0; +static int maximum_allocation = 0; +static int total_allocation = 0; +static int num_allocations = 0; png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, png_alloc_size_t size)); @@ -604,10 +595,9 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) if (pinfo->pointer == ptr) { *ppinfo = pinfo->next; - if (current_allocation < pinfo->size) + current_allocation -= pinfo->size; + if (current_allocation < 0) fprintf(STDERR, "Duplicate free of memory\n"); - else - current_allocation -= pinfo->size; /* We must free the list element too, but first kill the memory that is to be freed. */ memset(ptr, 0x55, pinfo->size); @@ -939,12 +929,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) read_user_chunk_callback); #endif -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -# ifdef CHUNK_LIMIT /* from the build, for testing */ - png_set_chunk_malloc_max(read_ptr, CHUNK_LIMIT); -# endif /* CHUNK_LIMIT */ -#endif - #ifdef PNG_SETJMP_SUPPORTED pngtest_debug("Setting jmpbuf for read struct"); if (setjmp(png_jmpbuf(read_ptr))) @@ -1002,9 +986,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) /* Allow application (pngtest) errors and warnings to pass */ png_set_benign_errors(read_ptr, 1); + /* Turn off CRC and ADLER32 checking while reading */ + png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); + # ifdef PNG_WRITE_SUPPORTED png_set_benign_errors(write_ptr, 1); # endif + } #endif /* BENIGN_ERRORS */ @@ -1404,6 +1392,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_write_info(write_ptr, write_info_ptr); write_chunks(write_ptr, before_IDAT); /* after PLTE */ + +#ifdef PNG_COMPRESSION_COMPAT + /* Test the 'compatibility' setting here, if it is available. */ + png_set_compression(write_ptr, PNG_COMPRESSION_COMPAT); +#endif #endif #ifdef SINGLE_ROWBUF_ALLOC @@ -1885,7 +1878,7 @@ main(int argc, char *argv[]) { int i; #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - png_alloc_size_t allocation_now = current_allocation; + int allocation_now = current_allocation; #endif for (i=2; i