Files libpng-1.2.29/contrib/gregbook/toucan.png and libpng-1.2.30/contrib/gregbook/toucan.png differ diff -ru4NwbB libpng-1.2.29/contrib/visupng/cexcept.h libpng-1.2.30/contrib/visupng/cexcept.h --- libpng-1.2.29/contrib/visupng/cexcept.h 2001-07-11 23:00:00.000000000 -0500 +++ libpng-1.2.30/contrib/visupng/cexcept.h 2008-08-02 07:11:44.664492000 -0500 @@ -1,26 +1,31 @@ /*=== -cexcept.h 2.0.0 (2001-Jul-12-Thu) -Adam M. Costello +cexcept.h 2.0.1 (2008-Jul-19-Sat) +http://www.nicemice.net/cexcept/ +Adam M. Costello +http://www.nicemice.net/amc/ An interface for exception-handling in ANSI C (C89 and subsequent ISO -standards), developed jointly with Cosmin Truta . +standards), developed jointly with Cosmin Truta. - Copyright (c) 2001 Adam M. Costello and Cosmin Truta. Everyone - is hereby granted permission to do whatever they like with this - file, provided that if they modify it they take reasonable steps to - avoid confusing or misleading people about the authors, version, - and terms of use of the derived file. The copyright holders make - no guarantees regarding this file, and are not responsible for any - damage resulting from its use. + Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta. + This software may be modified only if its author and version + information is updated accurately, and may be redistributed + only if accompanied by this unaltered notice. Subject to those + restrictions, permission is granted to anyone to do anything + with this software. The copyright holders make no guarantees + regarding this software, and are not responsible for any damage + resulting from its use. + +The cexcept interface is not compatible with and cannot interact +with system exceptions (like division by zero or memory segmentation +violation), compiler-generated exceptions (like C++ exceptions), or +other exception-handling interfaces. -Only user-defined exceptions are supported, not "real" exceptions like -division by zero or memory segmentation violations. - -If this interface is used by multiple .c files, they shouldn't include +When using this interface across multiple .c files, do not include this header file directly. Instead, create a wrapper header file that includes this header file and then invokes the define_exception_type -macro (see below), and let your .c files include that header file. +macro (see below). The .c files should then include that header file. The interface consists of one type, one well-known name, and six macros. @@ -163,9 +168,9 @@ clause of the innermost enclosing Try clause. The expression must be compatible with the type passed to define_exception_type(). The exception must be caught, otherwise the program may crash. - Slight limitation: If the expression is a comma-expression it must + Slight limitation: If the expression is a comma-expression, it must be enclosed in parentheses. Try statement @@ -208,13 +213,13 @@ jmp_buf *exception__prev, exception__env; \ exception__prev = the_exception_context->penv; \ the_exception_context->penv = &exception__env; \ if (setjmp(exception__env) == 0) { \ - if (&exception__prev) + do #define exception__catch(action) \ - else { } \ - the_exception_context->caught = 0; \ + while (the_exception_context->caught = 0, \ + the_exception_context->caught); \ } \ else { \ the_exception_context->caught = 1; \ } \ @@ -225,16 +230,16 @@ #define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) #define Catch_anonymous exception__catch(0) -/* Try ends with if(), and Catch begins and ends with else. This */ -/* ensures that the Try/Catch syntax is really the same as the */ -/* if/else syntax. */ +/* Try ends with do, and Catch begins with while(0) and ends with */ +/* else, to ensure that Try/Catch syntax is similar to if/else */ +/* syntax. */ /* */ -/* We use &exception__prev instead of 1 to appease compilers that */ -/* warn about constant expressions inside if(). Most compilers */ -/* should still recognize that &exception__prev is never zero and */ -/* avoid generating test code. */ +/* The 0 in while(0) is expressed as x=0,x in order to appease */ +/* compilers that warn about constant expressions inside while(). */ +/* Most compilers should still recognize that the condition is always */ +/* false and avoid generating code for it. */ #define Throw \ for (;; longjmp(*the_exception_context->penv, 1)) \ the_exception_context->v.etmp = diff -ru4NwbB libpng-1.2.29/example.c libpng-1.2.30/example.c --- libpng-1.2.29/example.c 2008-05-08 06:58:06.712657042 -0500 +++ libpng-1.2.30/example.c 2008-08-15 09:14:43.106149277 -0500 @@ -1,11 +1,11 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.2.1 December 7, 2001. + * Last changed in libpng 1.2.30 [August 15, 2008] * This file has been placed in the public domain by the authors. - * Maintained 1998-2007 Glenn Randers-Pehrson + * Maintained 1998-2008 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ diff -ru4NwbB libpng-1.2.29/png.c libpng-1.2.30/png.c --- libpng-1.2.29/png.c 2008-05-08 06:58:06.742636853 -0500 +++ libpng-1.2.30/png.c 2008-08-15 09:14:43.112851987 -0500 @@ -1,10 +1,10 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.21 October 4, 2007 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) */ @@ -379,13 +379,13 @@ if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) #endif { png_free(png_ptr, info_ptr->trans); + info_ptr->trans = NULL; info_ptr->valid &= ~PNG_INFO_tRNS; #ifndef PNG_FREE_ME_SUPPORTED png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif - info_ptr->trans = NULL; } #endif #if defined(PNG_sCAL_SUPPORTED) diff -ru4NwbB libpng-1.2.29/png.h libpng-1.2.30/png.h --- libpng-1.2.29/png.h 2008-05-08 06:58:06.626031117 -0500 +++ libpng-1.2.30/png.h 2008-08-15 09:14:43.090369603 -0500 @@ -191,8 +191,14 @@ * 1.2.29beta01-03 13 10229 12.so.0.29[.0] * 1.2.29rc01 13 10229 12.so.0.29[.0] * 1.0.35 10 10035 10.so.0.35[.0] * 1.2.29 13 10229 12.so.0.29[.0] + * 1.0.37 10 10037 10.so.0.37[.0] + * 1.2.30beta01-04 13 10230 12.so.0.30[.0] + * 1.0.38rc01-08 10 10038 10.so.0.38[.0] + * 1.2.30rc01-08 13 10230 12.so.0.30[.0] + * 1.0.38 10 10038 10.so.0.38[.0] + * 1.2.30 13 10230 12.so.0.30[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The @@ -1203,9 +1209,9 @@ png_uint_32 iwidth; /* width of current interlaced row in pixels */ png_uint_32 row_number; /* current row in interlace pass */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */ -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */ png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ @@ -1443,8 +1449,12 @@ #endif /* New members added in libpng-1.2.26 */ png_uint_32 old_big_row_buf_size, old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + }; /* This triggers a compiler error in png.c, if png.c and png.h @@ -3025,10 +3036,10 @@ /* Decompress data in a chunk that uses compression */ #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, png_size_t prefix_length, png_size_t *data_length)); #endif /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ @@ -3555,8 +3566,11 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ diff -ru4NwbB libpng-1.2.29/pngerror.c libpng-1.2.30/pngerror.c --- libpng-1.2.29/pngerror.c 2008-05-08 06:58:06.759790623 -0500 +++ libpng-1.2.30/pngerror.c 2008-08-15 09:14:43.118197127 -0500 @@ -1,10 +1,10 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.22 [October 13, 2007] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) * * This file provides a location for all error handling. Users who @@ -43,18 +43,19 @@ (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) { if (*error_message == '#') { + /* Strip "#nnnn " from beginning of error message. */ int offset; for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') + if (error_message[offset] == ' ') break; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { int i; for (i=0; iwarning_fn != NULL) @@ -215,21 +216,22 @@ #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == '#') { + /* Strip "#nnnn " from beginning of warning message. */ int offset; char error_number[16]; for (offset=0; offset<15; offset++) { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') + error_number[offset] = error_message[offset + 1]; + if (error_message[offset] == ' ') break; } if((offset > 1) && (offset < 15)) { error_number[offset-1]='\0'; fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); + error_message + offset + 1); } else fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); } @@ -275,15 +277,15 @@ int offset; char warning_number[16]; for (offset=0; offset<15; offset++) { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') + warning_number[offset] = warning_message[offset + 1]; + if (warning_message[offset] == ' ') break; } if((offset > 1) && (offset < 15)) { - warning_number[offset-1]='\0'; + warning_number[offset + 1] = '\0'; fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, warning_message+offset); } else diff -ru4NwbB libpng-1.2.29/pngget.c libpng-1.2.30/pngget.c --- libpng-1.2.29/pngget.c 2008-05-08 06:58:06.802614755 -0500 +++ libpng-1.2.30/pngget.c 2008-08-15 09:14:43.129779098 -0500 @@ -1,10 +1,10 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.15 January 5, 2007 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) */ diff -ru4NwbB libpng-1.2.29/pngmem.c libpng-1.2.30/pngmem.c --- libpng-1.2.29/pngmem.c 2008-05-08 06:58:06.827166578 -0500 +++ libpng-1.2.30/pngmem.c 2008-08-15 09:14:43.135628764 -0500 @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -586,9 +586,10 @@ void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - if(png_ptr != NULL) { + if (png_ptr != NULL) + { png_ptr->mem_ptr = mem_ptr; png_ptr->malloc_fn = malloc_fn; png_ptr->free_fn = free_fn; } diff -ru4NwbB libpng-1.2.29/pngpread.c libpng-1.2.30/pngpread.c --- libpng-1.2.29/pngpread.c 2008-05-08 06:58:06.879461236 -0500 +++ libpng-1.2.30/pngpread.c 2008-08-15 09:14:43.143235273 -0500 @@ -1,8 +1,8 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -212,8 +211,9 @@ png_push_fill_buffer(png_ptr, chunk_length, 4); png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) @@ -221,12 +221,12 @@ 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) - { if (png_ptr->push_length != 13) png_error(png_ptr, "Invalid IHDR length"); + if (png_ptr->push_length + 4 > png_ptr->buffer_size) + { png_push_save_buffer(png_ptr); return; } png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); @@ -1019,39 +1019,34 @@ png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { - int pass; - pass = png_ptr->pass; - pass++; - if ((pass == 1 && png_ptr->width < 5) || - (pass == 3 && png_ptr->width < 3) || - (pass == 5 && png_ptr->width < 2)) - pass++; - - if (pass > 7) - pass--; - png_ptr->pass = (png_byte) pass; - if (pass < 7) - { + png_ptr->pass++; + if ((png_ptr->pass == 1 && png_ptr->width < 5) || + (png_ptr->pass == 3 && png_ptr->width < 3) || + (png_ptr->pass == 5 && png_ptr->width < 2)) + png_ptr->pass++; + + if (png_ptr->pass > 7) + png_ptr->pass--; + if (png_ptr->pass >= 7) + break; + png_ptr->iwidth = (png_ptr->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1; if (png_ptr->transformations & PNG_INTERLACE) break; png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[pass] - 1 - - png_pass_ystart[pass]) / - png_pass_yinc[pass]; - } - else - break; + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } } @@ -1267,10 +1262,10 @@ { if (text == NULL) { text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); + (png_uint_32)(png_ptr->zbuf_size + - png_ptr->zstream.avail_out + key_size + 1)); png_memcpy(text + key_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); png_memcpy(text, key, key_size); text_size = key_size + png_ptr->zbuf_size - @@ -1282,10 +1277,10 @@ png_charp tmp; tmp = text; text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); + (png_uint_32)(png_ptr->zbuf_size + - png_ptr->zstream.avail_out)); png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); png_memcpy(text + text_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); @@ -1468,9 +1463,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); if (!(png_ptr->chunk_name[0] & 0x20)) { #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) @@ -1499,16 +1493,18 @@ #endif png_memcpy((png_charp)png_ptr->unknown_chunk.name, (png_charp)png_ptr->chunk_name, png_sizeof(png_ptr->unknown_chunk.name)); - png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0'; + png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1] + = '\0'; png_ptr->unknown_chunk.size = (png_size_t)length; if (length == 0) png_ptr->unknown_chunk.data = NULL; else { - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); + png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, + (png_uint_32)length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) if(png_ptr->read_user_chunk_fn != NULL) diff -ru4NwbB libpng-1.2.29/pngread.c libpng-1.2.30/pngread.c --- libpng-1.2.29/pngread.c 2008-05-08 06:58:06.932390540 -0500 +++ libpng-1.2.30/pngread.c 2008-08-15 09:14:43.151085258 -0500 @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.25 [February 18, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -34,8 +33,11 @@ png_malloc_ptr malloc_fn, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ +#ifdef PNG_SETJMP_SUPPORTED + volatile +#endif png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD @@ -405,40 +407,31 @@ #if defined(PNG_READ_zTXt_SUPPORTED) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); + png_uint_32 length = png_read_chunk_header(png_ptr); + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; /* 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_IDAT, 4)) + if (!png_memcmp(chunk_name, 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_memcmp(chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + else if (!png_memcmp(chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if (png_handle_as_unknown(png_ptr, chunk_name)) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (!png_memcmp(chunk_name, png_IDAT, 4)) png_ptr->mode |= PNG_HAVE_IDAT; png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + if (!png_memcmp(chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && @@ -447,11 +440,11 @@ break; } } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && @@ -462,73 +455,73 @@ png_ptr->mode |= PNG_HAVE_IDAT; break; } #if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); @@ -702,17 +695,11 @@ if (!(png_ptr->zstream.avail_in)) { while (!png_ptr->idat_size) { - png_byte chunk_length[4]; - png_crc_finish(png_ptr, 0); - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_ptr->idat_size = png_read_chunk_header(png_ptr); if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_error(png_ptr, "Not enough image data"); } png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; @@ -919,11 +906,8 @@ */ void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr) { - png_byte chunk_length[4]; - png_uint_32 length; - png_debug(1, "in png_read_end\n"); if(png_ptr == NULL) return; png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ @@ -985,111 +969,105 @@ #if defined(PNG_READ_zTXt_SUPPORTED) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ + png_uint_32 length = png_read_chunk_header(png_ptr); + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (!png_memcmp(chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + else if (!png_memcmp(chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if (png_handle_as_unknown(png_ptr, chunk_name)) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (!png_memcmp(chunk_name, png_IDAT, 4)) { if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); } png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + if (!png_memcmp(chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { /* 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_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); png_crc_finish(png_ptr, length); } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); #if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); @@ -1110,11 +1088,9 @@ #endif png_debug(1, "in png_destroy_read_struct\n"); if (png_ptr_ptr != NULL) - { png_ptr = *png_ptr_ptr; - } if (png_ptr == NULL) return; #ifdef PNG_USER_MEM_SUPPORTED @@ -1158,16 +1134,19 @@ #endif *end_info_ptr_ptr = NULL; } + if (png_ptr != NULL) + { #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else png_destroy_struct((png_voidp)png_ptr); #endif *png_ptr_ptr = NULL; } +} /* free all memory used by the read (old method) */ void /* PRIVATE */ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) @@ -1191,8 +1170,9 @@ png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); png_free(png_ptr, png_ptr->prev_row); + png_free(png_ptr, png_ptr->chunkdata); #if defined(PNG_READ_DITHER_SUPPORTED) png_free(png_ptr, png_ptr->palette_lookup); png_free(png_ptr, png_ptr->dither_index); #endif diff -ru4NwbB libpng-1.2.29/pngrio.c libpng-1.2.30/pngrio.c --- libpng-1.2.29/pngrio.c 2008-05-08 06:58:06.950694587 -0500 +++ libpng-1.2.30/pngrio.c 2008-08-15 09:14:43.156377598 -0500 @@ -1,10 +1,10 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.13 November 13, 2006 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) * * This file provides a location for all input. Users who need diff -ru4NwbB libpng-1.2.29/pngrtran.c libpng-1.2.30/pngrtran.c --- libpng-1.2.29/pngrtran.c 2008-05-08 06:58:07.093653212 -0500 +++ libpng-1.2.30/pngrtran.c 2008-08-15 09:14:43.169824067 -0500 @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -38,9 +37,10 @@ png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); + png_warning(png_ptr, + "Can't discard critical data on CRC error."); case PNG_CRC_ERROR_QUIT: /* error/quit */ case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; @@ -658,9 +658,10 @@ #if defined(PNG_READ_EXPAND_SUPPORTED) png_ptr->transformations |= PNG_EXPAND; #else { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + png_warning(png_ptr, + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); png_ptr->transformations &= ~PNG_RGB_TO_GRAY; } #endif { @@ -682,9 +683,10 @@ green_int = 23434; } png_ptr->rgb_to_gray_red_coeff = red_int; png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); + png_ptr->rgb_to_gray_blue_coeff = + (png_uint_16)(32768 - red_int - green_int); } } #endif @@ -1272,9 +1274,9 @@ #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char msg[50]; png_snprintf2(msg, 50, - "NULL row buffer for row %ld, pass %d", png_ptr->row_number, + "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number, png_ptr->pass); png_error(png_ptr, msg); #else png_error(png_ptr, "NULL row buffer"); @@ -2209,10 +2211,12 @@ #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) /* reduce RGB files to grayscale, with or without alpha * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net + * (THIS LINK IS DEAD June 2008) + * New link: + * + * Charles Poynton poynton at poynton.com * * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B * * We approximate this with diff -ru4NwbB libpng-1.2.29/pngrutil.c libpng-1.2.30/pngrutil.c --- libpng-1.2.29/pngrutil.c 2008-05-08 06:58:07.189732302 -0500 +++ libpng-1.2.30/pngrutil.c 2008-08-15 09:14:43.181512697 -0500 @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -29,9 +28,9 @@ int len; wchar_t *str, *end; len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); + str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t)); if ( NULL != str ) { MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); result = wcstod(str, &end); @@ -48,9 +47,17 @@ png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf) { +#ifdef PNG_READ_BIG_ENDIAN_SUPPORTED png_uint_32 i = png_get_uint_32(buf); +#else + /* Avoid an extra function call by inlining the result. */ + png_uint_32 i = ((png_uint_32)(*buf) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + (png_uint_32)(*(buf + 3)); +#endif if (i > PNG_UINT_31_MAX) png_error(png_ptr, "PNG unsigned integer out of range."); return (i); } @@ -91,8 +98,37 @@ return (i); } #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ +/* Read the chunk header (length + type name). + * Put the type name into png_ptr->chunk_name, and return the length. + */ +png_uint_32 /* PRIVATE */ +png_read_chunk_header(png_structp png_ptr) +{ + png_byte buf[8]; + png_uint_32 length; + + /* read the length and the chunk name */ + png_read_data(png_ptr, buf, 8); + length = png_get_uint_31(png_ptr, buf); + + /* put the chunk name into png_ptr->chunk_name */ + png_memcpy(png_ptr->chunk_name, buf + 4, 4); + + png_debug2(0, "Reading %s chunk, length = %lu\n", + png_ptr->chunk_name, length); + + /* reset the crc and run it over the chunk name */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, png_ptr->chunk_name, 4); + + /* check to see if chunk name is valid */ + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + return length; +} + /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) { @@ -179,11 +215,11 @@ * trailing compressed part. What we get back is an allocated area * holding the original prefix part and an uncompressed version of the * trailing part (the malloc area passed in is freed). */ -png_charp /* PRIVATE */ +void /* PRIVATE */ png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, + png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength) { static PNG_CONST char msg[] = "Error decoding compressed text"; png_charp text; @@ -191,9 +227,9 @@ if (comp_type == PNG_COMPRESSION_TYPE_BASE) { int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); + png_ptr->zstream.next_in = (png_bytep)(png_ptr->chunkdata + prefix_size); png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; @@ -217,20 +253,22 @@ text_size = prefix_size + png_sizeof(msg) + 1; text = (png_charp)png_malloc_warn(png_ptr, text_size); if (text == NULL) { - png_free(png_ptr,chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_error(png_ptr,"Not enough memory to decompress chunk"); } - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); } text[text_size - 1] = 0x00; /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); + text_size = (png_size_t)(chunklength - + (text - png_ptr->chunkdata) - 1); + if (text_size > png_sizeof(msg)) + text_size = png_sizeof(msg); png_memcpy(text + prefix_size, msg, text_size); break; } if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) @@ -241,14 +279,16 @@ png_ptr->zbuf_size - png_ptr->zstream.avail_out; text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); if (text == NULL) { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, + "Not enough memory to decompress chunk."); } png_memcpy(text + prefix_size, png_ptr->zbuf, text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); *(text + text_size) = 0x00; } else { @@ -260,10 +300,12 @@ png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); if (text == NULL) { png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, + "Not enough memory to decompress chunk.."); } png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); png_memcpy(text + text_size, png_ptr->zbuf, @@ -307,40 +349,38 @@ { text = (png_charp)png_malloc_warn(png_ptr, text_size+1); if (text == NULL) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_error(png_ptr,"Not enough memory for text."); } - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); } *(text + text_size) = 0x00; } inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; - png_free(png_ptr, chunkdata); - chunkdata = text; + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = text; *newlength=text_size; } else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char umsg[50]; - png_snprintf(umsg, 50, - "Unknown zTXt compression type %d", comp_type); + png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type); png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Unknown zTXt compression type"); #endif - *(chunkdata + prefix_size) = 0x00; + *(png_ptr->chunkdata + prefix_size) = 0x00; *newlength=prefix_size; } - - return chunkdata; } #endif /* read and check the IDHR chunk */ @@ -724,9 +764,9 @@ #if defined(PNG_READ_cHRM_SUPPORTED) void /* PRIVATE */ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_byte buf[4]; + png_byte buf[32]; #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, @@ -765,64 +805,48 @@ png_crc_finish(png_ptr, length); return; } - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); + png_crc_read(png_ptr, buf, 32); + if (png_crc_finish(png_ptr, 0)) + return; + uint_x = png_get_uint_32(buf); + uint_y = png_get_uint_32(buf + 4); if (uint_x > 80000L || uint_y > 80000L || uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); return; } int_x_white = (png_fixed_point)uint_x; int_y_white = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - + uint_x = png_get_uint_32(buf + 8); + uint_y = png_get_uint_32(buf + 12); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); return; } int_x_red = (png_fixed_point)uint_x; int_y_red = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - + uint_x = png_get_uint_32(buf + 16); + uint_y = png_get_uint_32(buf + 20); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); return; } int_x_green = (png_fixed_point)uint_x; int_y_green = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - + uint_x = png_get_uint_32(buf + 24); + uint_y = png_get_uint_32(buf + 28); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); return; } int_x_blue = (png_fixed_point)uint_x; int_y_blue = (png_fixed_point)uint_y; @@ -865,9 +889,8 @@ int_x_green, int_y_green, int_x_blue, int_y_blue); #endif #endif /* PNG_NO_CONSOLE_IO */ } - png_crc_finish(png_ptr, 0); return; } #endif /* PNG_READ_sRGB_SUPPORTED */ @@ -948,9 +971,10 @@ png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO # ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); + fprintf(stderr, "incorrect gamma=(%d/100000)\n", + (int)png_ptr->int_gamma); # else # ifdef PNG_FLOATING_POINT_SUPPORTED fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); # endif @@ -986,9 +1010,8 @@ void /* PRIVATE */ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_charp chunkdata; png_byte compression_type; png_bytep pC; png_charp profile; png_uint_32 skip = 0; @@ -1024,30 +1047,33 @@ length = (png_uint_32)65535L; } #endif - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (profile = chunkdata; *profile; profile++) + for (profile = png_ptr->chunkdata; *profile; profile++) /* empty loop to find end of name */ ; ++profile; /* there should be at least one zero (the compression type byte) following the separator, and we should be on it */ - if ( profile >= chunkdata + slength - 1) + if ( profile >= png_ptr->chunkdata + slength - 1) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Malformed iCCP chunk"); return; } @@ -1059,23 +1085,24 @@ compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 wrote nonzero) */ } - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, + prefix_length = profile - png_ptr->chunkdata; + png_decompress_chunk(png_ptr, compression_type, slength, prefix_length, &data_length); profile_length = data_length - prefix_length; if ( prefix_length > data_length || profile_length < 4) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Profile size field missing from iCCP chunk"); return; } /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); + pC = (png_bytep)(png_ptr->chunkdata + prefix_length); profile_size = ((*(pC ))<<24) | ((*(pC+1))<<16) | ((*(pC+2))<< 8) | ((*(pC+3)) ); @@ -1084,25 +1111,26 @@ profile_length = profile_size; if(profile_size > profile_length) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Ignoring truncated iCCP profile."); return; } - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); + png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata, + compression_type, png_ptr->chunkdata + prefix_length, profile_length); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; } #endif /* PNG_READ_iCCP_SUPPORTED */ #if defined(PNG_READ_sPLT_SUPPORTED) void /* PRIVATE */ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_bytep chunkdata; png_bytep entry_start; png_sPLT_t new_palette; #ifdef PNG_NO_POINTER_INDEXING png_sPLT_entryp pp; @@ -1130,47 +1158,51 @@ length = (png_uint_32)65535L; } #endif - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (entry_start = chunkdata; *entry_start; entry_start++) + for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start; entry_start++) /* empty loop to find end of name */ ; ++entry_start; /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength - 2) + if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "malformed sPLT chunk"); return; } new_palette.depth = *entry_start++; entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); + data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata)); /* integrity-check the data length */ if (data_length % entry_size) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "sPLT chunk has bad length"); return; } new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) + if ((png_uint_32) new_palette.nentries > + (png_uint_32) (PNG_SIZE_MAX / png_sizeof(png_sPLT_entry))) { png_warning(png_ptr, "sPLT chunk too long"); return; } @@ -1226,13 +1258,14 @@ } #endif /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; + new_palette.name = png_ptr->chunkdata; png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ @@ -1564,9 +1597,8 @@ /* read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_charp purpose; png_int_32 X0, X1; png_byte type, nparams; png_charp buf, units, endptr; png_charpp params; @@ -1591,37 +1623,40 @@ } png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "No memory for pCAL purpose."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - purpose[slength] = 0x00; /* null terminate the last string */ + png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */ png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) + for (buf = png_ptr->chunkdata; *buf; buf++) /* empty loop */ ; - endptr = purpose + slength; + endptr = png_ptr->chunkdata + slength; /* We need to have at least 12 bytes after the purpose string in order to get the parameter information. */ if (endptr <= buf + 12) { png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); @@ -1639,9 +1674,10 @@ (type == PNG_EQUATION_ARBITRARY && nparams != 3) || (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) { png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else if (type >= PNG_EQUATION_LAST) { @@ -1651,13 +1687,14 @@ for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; + params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_charp))) ; if (params == NULL) { - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "No memory for pCAL params."); return; } @@ -1673,18 +1710,20 @@ /* Make sure we haven't run out of data yet */ if (buf > endptr) { png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, params); return; } } - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, + png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, units, params); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, params); } #endif @@ -1692,9 +1731,9 @@ /* read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_charp buffer, ep; + png_charp ep; #ifdef PNG_FLOATING_POINT_SUPPORTED double width, height; png_charp vp; #else @@ -1722,26 +1761,27 @@ } png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "Out of memory while processing sCAL chunk"); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - buffer[slength] = 0x00; /* null terminate the last string */ + png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */ - ep = buffer + 1; /* skip unit byte */ + ep = png_ptr->chunkdata + 1; /* skip unit byte */ #ifdef PNG_FLOATING_POINT_SUPPORTED width = png_strtod(png_ptr, ep, &vp); if (*vp) @@ -1760,20 +1800,21 @@ png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); #endif #endif - for (ep = buffer; *ep; ep++) + for (ep = png_ptr->chunkdata; *ep; ep++) /* empty loop */ ; ep++; - if (buffer + slength < ep) + if (png_ptr->chunkdata + slength < ep) { png_warning(png_ptr, "Truncated sCAL chunk"); #if defined(PNG_FIXED_POINT_SUPPORTED) && \ !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); #endif - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } #ifdef PNG_FLOATING_POINT_SUPPORTED @@ -1794,16 +1835,17 @@ png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); #endif #endif - if (buffer + slength < ep + if (png_ptr->chunkdata + slength < ep #ifdef PNG_FLOATING_POINT_SUPPORTED || width <= 0. || height <= 0. #endif ) { png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); #endif @@ -1811,16 +1853,17 @@ } #ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); + png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height); #else #ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); + png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight); #endif #endif - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); #endif @@ -1954,9 +1997,8 @@ void /* PRIVATE */ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; - png_charp chunkdata; png_charp text; int comp_type; int ret; png_size_t slength, prefix_len, data_len; @@ -1978,32 +2020,35 @@ return; } #endif - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + png_free(png_ptr,png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr,"Out of memory processing zTXt chunk."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (text = chunkdata; *text; text++) + for (text = png_ptr->chunkdata; *text; text++) /* empty loop */ ; /* zTXt must have some text after the chunkdataword */ - if (text >= chunkdata + slength - 2) + if (text >= png_ptr->chunkdata + slength - 2) { png_warning(png_ptr, "Truncated zTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else { @@ -2014,35 +2059,37 @@ comp_type = PNG_TEXT_COMPRESSION_zTXt; } text++; /* skip the compression_method byte */ } - prefix_len = text - chunkdata; + prefix_len = text - png_ptr->chunkdata; - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, + png_decompress_chunk(png_ptr, comp_type, (png_size_t)length, prefix_len, &data_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } text_ptr->compression = comp_type; - text_ptr->key = chunkdata; + text_ptr->key = png_ptr->chunkdata; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; #endif - text_ptr->text = chunkdata + prefix_len; + text_ptr->text = png_ptr->chunkdata + prefix_len; text_ptr->text_length = data_len; ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; if (ret) png_error(png_ptr, "Insufficient memory to store zTXt chunk."); } #endif @@ -2052,9 +2099,8 @@ void /* PRIVATE */ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; - png_charp chunkdata; png_charp key, lang, text, lang_key; int comp_flag; int comp_type = 0; int ret; @@ -2078,36 +2124,39 @@ return; } #endif - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "No memory to process iTXt chunk."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (lang = chunkdata; *lang; lang++) + for (lang = png_ptr->chunkdata; *lang; lang++) /* empty loop */ ; lang++; /* skip NUL separator */ /* iTXt must have a language tag (possibly empty), two compression bytes, translated keyword (possibly empty), and possibly some text after the keyword */ - if (lang >= chunkdata + slength - 3) + if (lang >= png_ptr->chunkdata + slength - 3) { png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else { @@ -2118,53 +2167,57 @@ for (lang_key = lang; *lang_key; lang_key++) /* empty loop */ ; lang_key++; /* skip NUL separator */ - if (lang_key >= chunkdata + slength) + if (lang_key >= png_ptr->chunkdata + slength) { png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } for (text = lang_key; *text; text++) /* empty loop */ ; text++; /* skip NUL separator */ - if (text >= chunkdata + slength) + if (text >= png_ptr->chunkdata + slength) { png_warning(png_ptr, "Malformed iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - prefix_len = text - chunkdata; + prefix_len = text - png_ptr->chunkdata; - key=chunkdata; + key=png_ptr->chunkdata; if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, + png_decompress_chunk(png_ptr, comp_type, (size_t)length, prefix_len, &data_len); else - data_len=png_strlen(chunkdata + prefix_len); + data_len = png_strlen(png_ptr->chunkdata + prefix_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); + text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key); + text_ptr->lang = png_ptr->chunkdata + (lang - key); text_ptr->itxt_length = data_len; text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; + text_ptr->key = png_ptr->chunkdata; + text_ptr->text = png_ptr->chunkdata + prefix_len; ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; if (ret) png_error(png_ptr, "Insufficient memory to store iTXt chunk."); } #endif @@ -2189,10 +2242,8 @@ if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ png_ptr->mode |= PNG_AFTER_IDAT; } - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - if (!(png_ptr->chunk_name[0] & 0x20)) { #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != @@ -2999,9 +3050,9 @@ #endif #endif int max_pixel_depth; - png_uint_32 row_bytes; + png_size_t row_bytes; png_debug(1, "in png_read_start_row\n"); png_ptr->zstream.avail_in = 0; png_init_read_transformations(png_ptr); @@ -3018,13 +3069,10 @@ png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + png_ptr->irowbytes = + PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1; } else #endif /* PNG_READ_INTERLACING_SUPPORTED */ { diff -ru4NwbB libpng-1.2.29/pngset.c libpng-1.2.30/pngset.c --- libpng-1.2.29/pngset.c 2008-05-08 06:58:07.236966338 -0500 +++ libpng-1.2.30/pngset.c 2008-08-15 09:14:43.189133146 -0500 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -395,9 +394,10 @@ if (png_ptr == NULL || info_ptr == NULL) return; length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); + png_debug1(3, "allocating purpose for info (%lu bytes)\n", + (unsigned long)length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL purpose."); @@ -411,9 +411,10 @@ info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); + png_debug1(3, "allocating units for info (%lu bytes)\n", + (unsigned long)length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL units."); @@ -433,9 +434,10 @@ for (i = 0; i < nparams; i++) { length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); + png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, + (unsigned long)length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_params[i] == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL parameter."); @@ -481,9 +483,10 @@ info_ptr->scal_unit = (png_byte)unit; length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); + png_debug1(3, "allocating unit for info (%u bytes)\n", + (unsigned int)length); info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { png_warning(png_ptr, @@ -492,13 +495,15 @@ } png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); + png_debug1(3, "allocating unit for info (%u bytes)\n", + (unsigned int)length); info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_height == NULL) { png_free (png_ptr, info_ptr->scal_s_width); + info_ptr->scal_s_width = NULL; png_warning(png_ptr, "Memory allocation failed while processing sCAL."); return; } @@ -699,9 +704,10 @@ new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); if (new_iccp_profile == NULL) { png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); + png_warning(png_ptr, + "Insufficient memory to process iCCP profile."); return; } png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); @@ -834,13 +840,15 @@ textp->compression = text_ptr[i].compression; } textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); + (png_uint_32) + (key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) return(1); png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), + (png_uint_32) + (key_len + lang_len + lang_key_len + text_length + 4), (int)textp->key); png_memcpy(textp->key, text_ptr[i].key, (png_size_t)(key_len)); @@ -913,18 +921,20 @@ png_debug1(1, "in %s storage function\n", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) return; - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); - if (trans != NULL) { /* * It may not actually be necessary to set png_ptr->trans here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); +#endif + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, (png_uint_32)PNG_MAX_PALETTE_LENGTH); if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) @@ -964,17 +974,25 @@ #if defined(PNG_sPLT_SUPPORTED) void PNGAPI png_set_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries) +/* + * entries - array of png_sPLT_t structures + * to be added to the list of palettes + * in the info structure. + * nentries - number of palette structures to be + * added. + */ { png_sPLT_tp np; int i; if (png_ptr == NULL || info_ptr == NULL) return; np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); + (info_ptr->splt_palettes_num + nentries) * + (png_uint_32)png_sizeof(png_sPLT_t)); if (np == NULL) { png_warning(png_ptr, "No memory for sPLT palettes."); return; @@ -1000,9 +1018,9 @@ continue; } png_memcpy(to->name, from->name, length); to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); + (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); if (to->entries == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); @@ -1036,10 +1054,10 @@ if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) return; np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); + (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) * + png_sizeof(png_unknown_chunk))); if (np == NULL) { png_warning(png_ptr, "Out of memory while processing unknown chunk."); @@ -1067,9 +1085,10 @@ if (from->size == 0) to->data=NULL; else { - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); + to->data = (png_bytep)png_malloc_warn(png_ptr, + (png_uint_32)from->size); if (to->data == NULL) { png_warning(png_ptr, "Out of memory while processing unknown chunk."); @@ -1152,9 +1171,10 @@ if (chunk_list == NULL) return; old_num_chunks=png_ptr->num_chunk_list; new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); + (png_uint_32) + (5*(num_chunks + old_num_chunks))); if(png_ptr->chunk_list != NULL) { png_memcpy(new_list, png_ptr->chunk_list, (png_size_t)(5*old_num_chunks)); @@ -1204,9 +1224,10 @@ #endif #ifdef PNG_WRITE_SUPPORTED void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) +png_set_compression_buffer_size(png_structp png_ptr, + png_uint_32 size) { if (png_ptr == NULL) return; png_free(png_ptr, png_ptr->zbuf); @@ -1233,8 +1254,9 @@ { /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr != NULL) png_ptr->asm_flags = 0; + asm_flags = asm_flags; /* Quiet the compiler */ } /* this function was added to libpng 1.2.0 */ void PNGAPI @@ -1244,8 +1266,11 @@ { /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr == NULL) return; + /* Quiet the compiler */ + mmx_bitdepth_threshold = mmx_bitdepth_threshold; + mmx_rowbytes_threshold = mmx_rowbytes_threshold; } #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED diff -ru4NwbB libpng-1.2.29/pngtest.c libpng-1.2.30/pngtest.c --- libpng-1.2.29/pngtest.c 2008-05-08 06:58:07.289474599 -0500 +++ libpng-1.2.30/pngtest.c 2008-08-15 09:14:43.197291536 -0500 @@ -1,8 +1,8 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.2.27 - [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -98,13 +98,8 @@ /* defined so I can write to a file on gui/windowing platforms */ /* #define STDERR stderr */ #define STDERR stdout /* for DOS */ -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - /* In case a system header (e.g., on AIX) defined jmpbuf */ #ifdef jmpbuf # undef jmpbuf #endif @@ -113,8 +108,13 @@ #ifndef png_jmpbuf # define png_jmpbuf(png_ptr) png_ptr->jmpbuf #endif +/* example of using row callbacks to make a simple progress meter */ +static int status_pass = 1; +static int status_dots_requested = 0; +static int status_dots = 1; + void #ifdef PNG_1_0_X PNGAPI #endif @@ -435,10 +435,8 @@ png_error(png_ptr, "Write Error"); } } #endif /* USE_FAR_KEYWORD */ -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything * here if you don't want to. In the default configuration, png_ptr is @@ -464,8 +462,10 @@ pngtest_warning(png_ptr, message); /* We can return because png_error calls the default handler, which is * actually OK in this case. */ } +#endif /* PNG_NO_STDIO */ +/* END of code to validate stdio-free compilation */ /* START of code to validate memory allocation and deallocation */ #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG @@ -519,9 +519,10 @@ if (current_allocation > maximum_allocation) maximum_allocation = current_allocation; pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); /* Restore malloc_fn and free_fn */ - png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, + png_set_mem_fn(png_ptr, + png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); if (size != 0 && pinfo->pointer == NULL) { current_allocation -= size; @@ -590,8 +591,75 @@ } #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ /* END of code to test memory allocation/deallocation */ + +/* Demonstration of user chunk support of the sTER and vpAg chunks */ +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + +/* (sTER is a public chunk not yet understood by libpng. vpAg is a private +chunk used in ImageMagick to store "virtual page" size). */ + +static png_uint_32 user_chunk_data[4]; + + /* 0: sTER mode + 1 + * 1: vpAg width + * 2: vpAg height + * 3: vpAg units + */ + +static int read_user_chunk_callback(png_struct *png_ptr, + png_unknown_chunkp chunk) +{ + png_uint_32 + *user_chunk_data; + + /* Return one of the following: */ + /* return (-n); chunk had an error */ + /* return (0); did not recognize */ + /* return (n); success */ + + /* The unknown chunk structure contains the chunk data: + * png_byte name[5]; + * png_byte *data; + * png_size_t size; + * + * Note that libpng has already taken care of the CRC handling. + */ + + if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */ + chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */ + { + /* Found sTER chunk */ + if (chunk->size != 1) + return (-1); /* Error return */ + if (chunk->data[0] != 0 && chunk->data[0] != 1) + return (-1); /* Invalid mode */ + user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + user_chunk_data[0]=chunk->data[0]+1; + return (1); + } + if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ + chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ + return (0); /* Did not recognize */ + + /* Found ImageMagick vpAg chunk */ + + if (chunk->size != 9) + return (-1); /* Error return */ + + user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + + user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data); + user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4); + user_chunk_data[3]=(png_uint_32)chunk->data[8]; + + return (1); + +} +#endif +/* END of code to demonstrate user chunk support */ + /* Test one file */ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { @@ -650,29 +718,47 @@ } png_debug(0, "Allocating read and write structures\n"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + read_ptr = + png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + read_ptr = + png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif +#if defined(PNG_NO_STDIO) png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + user_chunk_data[0] = 0; + user_chunk_data[1] = 0; + user_chunk_data[2] = 0; + user_chunk_data[3] = 0; + png_set_read_user_chunk_fn(read_ptr, user_chunk_data, + read_user_chunk_callback); + +#endif #ifdef PNG_WRITE_SUPPORTED #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + write_ptr = + png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + write_ptr = + png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif +#if defined(PNG_NO_STDIO) png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif +#endif png_debug(0, "Allocating read_info, write_info and end_info structures\n"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); #ifdef PNG_WRITE_SUPPORTED @@ -689,8 +775,9 @@ #endif { fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); png_free(read_ptr, row_buf); + row_buf = NULL; png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr); @@ -912,9 +999,10 @@ { png_int_32 offset_x, offset_y; int unit_type; - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) + if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, + &unit_type)) { png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); } } @@ -1062,8 +1150,42 @@ /* If we wanted, we could write info in two steps: png_write_info_before_PLTE(write_ptr, write_info_ptr); */ png_write_info(write_ptr, write_info_ptr); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (user_chunk_data[0] != 0) + { + png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}; + + unsigned char + ster_chunk_data[1]; + + if (verbose) + fprintf(STDERR, "stereo mode = %lu\n", + (unsigned long)(user_chunk_data[0] - 1)); + ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1); + png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1); + } + if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0) + { + png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'}; + + unsigned char + vpag_chunk_data[9]; + + if (verbose) + fprintf(STDERR, "vpAg = %lu x %lu, units=%lu\n", + (unsigned long)user_chunk_data[1], + (unsigned long)user_chunk_data[2], + (unsigned long)user_chunk_data[3]); + png_save_uint_32(vpag_chunk_data, user_chunk_data[1]); + png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]); + vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff); + png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9); + } + +#endif #endif #ifdef SINGLE_ROWBUF_ALLOC png_debug(0, "\nAllocating row buffer..."); @@ -1118,8 +1240,9 @@ #ifndef SINGLE_ROWBUF_ALLOC png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); png_free(read_ptr, row_buf); + row_buf = NULL; #endif /* !SINGLE_ROWBUF_ALLOC */ } } @@ -1325,9 +1448,9 @@ png_get_header_version(NULL)); /* Show the version of libpng used in building the application */ fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, PNG_HEADER_VERSION_STRING); - fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", + fprintf(STDERR, " sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n", (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); /* Do some consistency checking on the memory allocation settings, I'm not sure this matters, but it is nice to know, the first of these @@ -1442,9 +1565,10 @@ fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", current_allocation); while (pinfo != NULL) { - fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size, + fprintf(STDERR, " %lu bytes at %x\n", + (unsigned long)pinfo->size, (unsigned int) pinfo->pointer); pinfo = pinfo->next; } } @@ -1491,9 +1615,10 @@ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) for (k=0; k<256; k++) if(filters_used[k]) fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); + k, + (unsigned long)filters_used[k]); #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) if(tIME_chunk_present != 0) fprintf(STDERR, " tIME = %s\n",tIME_string); diff -ru4NwbB libpng-1.2.29/pngtrans.c libpng-1.2.30/pngtrans.c --- libpng-1.2.29/pngtrans.c 2008-05-08 06:58:07.316495467 -0500 +++ libpng-1.2.30/pngtrans.c 2008-08-15 09:14:43.203929333 -0500 @@ -1,10 +1,10 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.17 May 15, 2007 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) */ @@ -651,10 +651,10 @@ */ png_voidp PNGAPI png_get_user_transform_ptr(png_structp png_ptr) { -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if (png_ptr == NULL) return (NULL); +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) return ((png_voidp)png_ptr->user_transform_ptr); #else return (NULL); #endif diff -ru4NwbB libpng-1.2.29/pngwio.c libpng-1.2.30/pngwio.c --- libpng-1.2.29/pngwio.c 2008-05-08 06:58:07.336780682 -0500 +++ libpng-1.2.30/pngwio.c 2008-08-15 09:14:43.213390293 -0500 @@ -1,10 +1,10 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.13 November 13, 2006 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 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.) * * This file provides a location for all output. Users who need diff -ru4NwbB libpng-1.2.29/pngwrite.c libpng-1.2.30/pngwrite.c --- libpng-1.2.29/pngwrite.c 2008-05-08 06:58:07.387852536 -0500 +++ libpng-1.2.30/pngwrite.c 2008-08-15 09:14:43.220975474 -0500 @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -392,8 +392,15 @@ png_ptr->mode |= PNG_AFTER_IDAT; /* write end of PNG file */ png_write_IEND(png_ptr); + /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, + * and restored again in libpng-1.2.30, may cause some applications that + * do not set png_ptr->output_flush_fn to crash. If your application + * experiences this problem, please report the event to + * png-mng-implement at lists.sf.net . + */ + png_flush(png_ptr); } #if defined(PNG_WRITE_tIME_SUPPORTED) #if !defined(_WIN32_WCE) @@ -438,8 +445,11 @@ png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ +#ifdef PNG_SETJMP_SUPPORTED + volatile +#endif png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD jmp_buf jmpbuf; @@ -1075,9 +1085,9 @@ /* free our memory. png_free checks NULL for us. */ png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->row_buf); -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->sub_row); png_free(png_ptr, png_ptr->up_row); png_free(png_ptr, png_ptr->avg_row); diff -ru4NwbB libpng-1.2.29/pngwutil.c libpng-1.2.30/pngwutil.c --- libpng-1.2.29/pngwutil.c 2008-05-08 06:58:07.499303498 -0500 +++ libpng-1.2.30/pngwutil.c 2008-08-15 09:14:43.237428850 -0500 @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 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.) @@ -48,8 +48,26 @@ buf[0] = (png_byte)((i >> 8) & 0xff); buf[1] = (png_byte)(i & 0xff); } +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. + */ +void /* PRIVATE */ +png_write_sig(png_structp png_ptr) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + + /* write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)(8 - png_ptr->sig_bytes)); + if (png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + /* Write a PNG chunk all at once. The type is an array of ASCII characters * representing the chunk name. The array must be at least 4 bytes in * length, and does not need to be null terminated. To be safe, pass the * pre-defined chunk names here, and if you need a new one, define it @@ -63,9 +81,9 @@ png_bytep data, png_size_t length) { if(png_ptr == NULL) return; png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); + png_write_chunk_data(png_ptr, data, (png_size_t)length); png_write_chunk_end(png_ptr); } /* Write the start of a PNG chunk. The type is the chunk type. @@ -75,18 +93,20 @@ void PNGAPI png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, png_uint_32 length) { - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); + png_byte buf[8]; + + png_debug2(0, "Writing %s chunk, length = %lu\n", chunk_name, + (unsigned long)length); if(png_ptr == NULL) return; - /* write the length */ + /* write the length and the chunk name */ png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); + png_memcpy(buf + 4, chunk_name, 4); + png_write_data(png_ptr, buf, (png_size_t)8); + /* put the chunk name into png_ptr->chunk_name */ + png_memcpy(png_ptr->chunk_name, chunk_name, 4); /* reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); } @@ -102,10 +122,13 @@ /* write the data, and run the CRC over it */ if(png_ptr == NULL) return; if (data != NULL && length > 0) { - png_calculate_crc(png_ptr, data, length); png_write_data(png_ptr, data, length); + /* update the CRC after writing the data, + * in case that the user I/O routine alters it. + */ + png_calculate_crc(png_ptr, data, length); } } /* Finish a chunk started with png_write_chunk_start(). */ @@ -115,31 +138,14 @@ png_byte buf[4]; if(png_ptr == NULL) return; - /* write the crc */ + /* write the crc in a single operation */ png_save_uint_32(buf, png_ptr->crc); png_write_data(png_ptr, buf, (png_size_t)4); } -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) /* * This pair of functions encapsulates the operation of (a) compressing a * text string, and (b) issuing it later as a series of chunk data writes. @@ -238,22 +244,23 @@ png_charpp old_ptr; old_ptr = comp->output_ptr; comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); + (png_uint_32) + (comp->max_output_ptr * png_sizeof(png_charpp))); png_memcpy(comp->output_ptr, old_ptr, old_max * png_sizeof (png_charp)); png_free(png_ptr, old_ptr); } else comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); + (png_uint_32) + (comp->max_output_ptr * png_sizeof(png_charp))); } /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, + comp->output_ptr[comp->num_output_ptr] = + (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); comp->num_output_ptr++; @@ -290,9 +297,9 @@ old_ptr = comp->output_ptr; /* This could be optimized to realloc() */ comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); + png_sizeof(png_charp))); png_memcpy(comp->output_ptr, old_ptr, old_max * png_sizeof (png_charp)); png_free(png_ptr, old_ptr); } @@ -303,9 +310,10 @@ } /* save off the data */ comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); + (png_charp)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); comp->num_output_ptr++; @@ -349,9 +357,9 @@ /* write saved output buffers, if any */ for (i = 0; i < comp->num_output_ptr; i++) { png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); + (png_size_t)png_ptr->zbuf_size); png_free(png_ptr, comp->output_ptr[i]); comp->output_ptr[i]=NULL; } if (comp->max_output_ptr != 0) @@ -359,9 +367,9 @@ comp->output_ptr=NULL; /* write anything left in zbuf */ if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); + (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out)); /* reset zlib for another zTXt/iTXt or image data */ deflateReset(&png_ptr->zstream); png_ptr->zstream.data_type = Z_BINARY; @@ -495,9 +503,9 @@ buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; /* write the chunk */ - png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); + png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); /* initialize zlib with PNG info */ png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; @@ -588,9 +596,10 @@ png_ptr->num_palette = (png_uint_16)num_pal; png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3); + png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, + (png_uint_32)(num_pal * 3)); #ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) { buf[0] = pal_ptr->red; @@ -660,9 +669,9 @@ png_error(png_ptr, "Invalid zlib compression method or flags in IDAT"); } - png_write_chunk(png_ptr, png_IDAT, data, length); + png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); png_ptr->mode |= PNG_HAVE_IDAT; } /* write an IEND chunk */ @@ -672,9 +681,9 @@ #ifdef PNG_USE_LOCAL_ARRAYS PNG_IEND; #endif png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, png_IEND, png_bytep_NULL, + png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } @@ -693,9 +702,9 @@ png_debug(1, "in png_write_gAMA\n"); /* file_gamma is saved in 1/100,000ths */ igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } #endif #ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ @@ -708,9 +717,9 @@ png_debug(1, "in png_write_gAMA\n"); /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } #endif #endif @@ -728,9 +737,9 @@ if(srgb_intent >= PNG_sRGB_INTENT_LAST) png_warning(png_ptr, "Invalid sRGB rendering intent specified"); buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); } #endif #if defined(PNG_WRITE_iCCP_SUPPORTED) @@ -789,16 +798,17 @@ profile_len = embedded_profile_len; } if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); + profile_len = png_text_compress(png_ptr, profile, + (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp); /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, png_iCCP, - (png_uint_32)name_len+profile_len+2); + png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, + (png_uint_32)(name_len + profile_len + 2)); new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 2)); if (profile_len) png_write_compressed_data_out(png_ptr, &comp); @@ -833,12 +843,13 @@ return; } /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, png_sPLT, + png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 1)); + png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1); /* loop through each palette entry, writing appropriately */ #ifndef PNG_NO_POINTER_INDEXING for (ep = spalette->entries; epentries+spalette->nentries; ep++) @@ -880,9 +891,9 @@ png_save_uint_16(entrybuf + 4, ep[i].blue); png_save_uint_16(entrybuf + 6, ep[i].alpha); png_save_uint_16(entrybuf + 8, ep[i].frequency); } - png_write_chunk_data(png_ptr, entrybuf, entry_size); + png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); } #endif png_write_chunk_end(png_ptr); @@ -941,9 +952,9 @@ } buf[size++] = sbit->alpha; } - png_write_chunk(png_ptr, png_sBIT, buf, size); + png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); } #endif #if defined(PNG_WRITE_cHRM_SUPPORTED) @@ -1005,9 +1016,9 @@ png_save_uint_32(buf + 24, itemp); itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); png_save_uint_32(buf + 28, itemp); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); } #endif #ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ @@ -1026,9 +1037,10 @@ if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) { png_warning(png_ptr, "Invalid fixed cHRM white point specified"); #if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); + fprintf(stderr, "white_x=%ld, white_y=%ld\n", (unsigned long)white_x, + (unsigned long)white_y); #endif return; } png_save_uint_32(buf, (png_uint_32)white_x); @@ -1057,9 +1069,9 @@ } png_save_uint_32(buf + 24, (png_uint_32)blue_x); png_save_uint_32(buf + 28, (png_uint_32)blue_y); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); } #endif #endif @@ -1082,9 +1094,10 @@ png_warning(png_ptr,"Invalid number of transparent colors specified"); return; } /* write the chunk out as it is */ - png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, + (png_size_t)num_trans); } else if (color_type == PNG_COLOR_TYPE_GRAY) { /* one 16 bit value */ @@ -1094,9 +1107,9 @@ "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); return; } png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); } else if (color_type == PNG_COLOR_TYPE_RGB) { /* three 16 bit values */ @@ -1108,9 +1121,9 @@ png_warning(png_ptr, "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); return; } - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); } else { png_warning(png_ptr, "Can't write tRNS with an alpha channel"); @@ -1141,9 +1154,9 @@ png_warning(png_ptr, "Invalid background palette index"); return; } buf[0] = back->index; - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); } else if (color_type & PNG_COLOR_MASK_COLOR) { png_save_uint_16(buf, back->red); @@ -1154,9 +1167,9 @@ png_warning(png_ptr, "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); return; } - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); } else { if(back->gray >= (1 << png_ptr->bit_depth)) @@ -1165,9 +1178,9 @@ "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); return; } png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); } } #endif @@ -1190,9 +1203,10 @@ png_warning(png_ptr, "Invalid number of histogram entries specified"); return; } - png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); + png_write_chunk_start(png_ptr, (png_bytep)png_hIST, + (png_uint_32)(num_hist * 2)); for (i = 0; i < num_hist; i++) { png_save_uint_16(buf, hist[i]); png_write_chunk_data(png_ptr, buf, (png_size_t)2); @@ -1356,18 +1370,20 @@ else text_len = png_strlen(text); /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1); + png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, + (png_uint_32)(key_len + text_len + 1)); /* * We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); + png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len); png_write_chunk_end(png_ptr); png_free(png_ptr, new_key); } @@ -1397,8 +1413,9 @@ if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) { png_warning(png_ptr, "Empty keyword in zTXt chunk"); + png_free(png_ptr, new_key); return; } if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) @@ -1414,12 +1431,13 @@ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp); /* write start of chunk */ - png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32) - (key_len+text_len+2)); + png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, + (png_uint_32)(key_len+text_len + 2)); /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); png_free(png_ptr, new_key); buf[0] = (png_byte)compression; /* write compression */ @@ -1482,9 +1500,9 @@ /* make sure we include the compression flag, the compression byte, * and the NULs after the key, lang, and lang_key parts */ - png_write_chunk_start(png_ptr, png_iTXt, + png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, (png_uint_32)( 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ + key_len + lang_len @@ -1496,9 +1514,10 @@ * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); /* set the compression flag */ if (compression == PNG_ITXT_COMPRESSION_NONE || \ compression == PNG_TEXT_COMPRESSION_NONE) @@ -1506,13 +1525,15 @@ else /* compression == PNG_ITXT_COMPRESSION_zTXt */ cbuf[0] = 1; /* set the compression method */ cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); + png_write_chunk_data(png_ptr, cbuf, (png_size_t)2); cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); + png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), + (png_size_t)(lang_len + 1)); + png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), + (png_size_t)(lang_key_len + 1)); png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); png_free(png_ptr, new_key); @@ -1538,9 +1559,9 @@ png_save_int_32(buf, x_offset); png_save_int_32(buf + 4, y_offset); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); } #endif #if defined(PNG_WRITE_pCAL_SUPPORTED) /* write the pCAL chunk (described in the PNG extensions document) */ @@ -1566,23 +1587,25 @@ units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); png_debug1(3, "pCAL units length = %d\n", (int)units_len); total_len = purpose_len + units_len + 10; - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); + params_len = (png_uint_32p)png_malloc(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_uint_32))); /* Find the length of each parameter, making sure we don't count the null terminator for the last parameter. */ for (i = 0; i < nparams; i++) { params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); + png_debug2(3, "pCAL parameter %d length = %lu\n", i, + (unsigned long) params_len[i]); total_len += (png_size_t)params_len[i]; } png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); + png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)new_purpose, + (png_size_t)purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf + 4, X1); buf[8] = (png_byte)type; buf[9] = (png_byte)nparams; @@ -1639,9 +1662,9 @@ total_len += png_strlen(buf + total_len); #endif png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); } #else #ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ @@ -1669,9 +1692,9 @@ 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_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, buf, total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); } #endif #endif #endif @@ -1695,9 +1718,9 @@ png_save_uint_32(buf, x_pixels_per_unit); png_save_uint_32(buf + 4, y_pixels_per_unit); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); } #endif #if defined(PNG_WRITE_tIME_SUPPORTED) @@ -1727,9 +1750,9 @@ buf[4] = mod_time->hour; buf[5] = mod_time->minute; buf[6] = mod_time->second; - png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7); + png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); } #endif /* initializes the row writing capability of libpng */ @@ -1760,49 +1783,51 @@ buf_size = (png_size_t)(PNG_ROWBYTES( png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)buf_size); png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER /* set up filtering buffer, if using this filter */ if (png_ptr->do_filter & PNG_FILTER_SUB) { png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } /* We only need to keep the previous row if we are using one of these. */ if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, + (png_uint_32)buf_size); png_memset(png_ptr->prev_row, 0, buf_size); if (png_ptr->do_filter & PNG_FILTER_UP) { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } if (png_ptr->do_filter & PNG_FILTER_AVG) { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } if (png_ptr->do_filter & PNG_FILTER_PAETH) { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } -#endif /* PNG_NO_WRITE_FILTERING */ } +#endif /* PNG_NO_WRITE_FILTER */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED /* if interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) diff -ru4NwbB libpng-1.2.29/scripts/libpng-config.in libpng-1.2.30/scripts/libpng-config.in --- libpng-1.2.29/scripts/libpng-config.in 2007-01-04 13:00:25.000000000 -0600 +++ libpng-1.2.30/scripts/libpng-config.in 2008-05-29 12:37:58.000000000 -0500 @@ -13,9 +13,9 @@ exec_prefix="@exec_prefix@" libdir="@libdir@" includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm" +all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@" I_opts="-I${includedir}" L_opts="-L${libdir}" R_opts="" cppflags="" diff -ru4NwbB libpng-1.2.29/scripts/libpng.pc-configure.in libpng-1.2.30/scripts/libpng.pc-configure.in --- libpng-1.2.29/scripts/libpng.pc-configure.in 2008-05-08 06:58:09.621391743 -0500 +++ libpng-1.2.30/scripts/libpng.pc-configure.in 2008-05-29 12:39:19.000000000 -0500 @@ -1,10 +1,11 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@/libpng%N% +includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ Name: libpng Description: Loads and saves PNG files -Version: 1.2.30 -Libs: -L${libdir} -lpng%N% +Version: @PNGLIB_VERSION@ +Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ +Libs.private: @LIBS@ Cflags: -I${includedir} @LIBPNG_NO_MMX@ diff -ru4NwbB libpng-1.2.29/scripts/makefile.aix libpng-1.2.30/scripts/makefile.aix --- libpng-1.2.29/scripts/makefile.aix 2008-05-08 06:58:09.734565059 -0500 +++ libpng-1.2.30/scripts/makefile.aix 2008-08-15 09:14:44.868838799 -0500 @@ -1,6 +1,6 @@ # makefile for libpng using gcc (generic, static library) -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta # Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h @@ -43,9 +43,9 @@ CDEBUG = -g -DPNG_DEBUG=5 LDDEBUG = CRELEASE = -O2 LDRELEASE = -s -WARNMORE=-Wall +WARNMORE=-W -Wall CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) LDFLAGS = -L. -L$(ZLIBLIB) -lpng%N% -lz -lm $(LDRELEASE) # File extensions diff -ru4NwbB libpng-1.2.29/scripts/makefile.beos libpng-1.2.30/scripts/makefile.beos --- libpng-1.2.29/scripts/makefile.beos 2008-05-08 06:58:09.768511915 -0500 +++ libpng-1.2.30/scripts/makefile.beos 2008-08-15 09:14:44.878625240 -0500 @@ -1,7 +1,7 @@ # makefile for libpng on BeOS x86 ELF with gcc # modified from makefile.linux by Sander Stoks -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -40,9 +40,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # On BeOS, -O1 is actually better than -O3. This is a known bug but it's # still here in R4.5 -CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 # LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz diff -ru4NwbB libpng-1.2.29/scripts/makefile.cygwin libpng-1.2.30/scripts/makefile.cygwin --- libpng-1.2.29/scripts/makefile.cygwin 2008-05-08 06:58:09.811920900 -0500 +++ libpng-1.2.30/scripts/makefile.cygwin 2008-08-15 09:14:44.888967392 -0500 @@ -2,9 +2,9 @@ # Builds both dll (with import lib) and static lib versions # of the library, and builds two copies of pngtest: one # statically linked and one dynamically linked. # -# Copyright (C) 2002, 2006, 2007 Soren Anderson, Charles Wilson, +# Copyright (C) 2002, 2006-2008 Soren Anderson, Charles Wilson, # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: # Copyright (C) 1998-2000 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -59,17 +59,17 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion ### if you don't need thread safety, but want the asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \ +# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### if you need thread safety and want (minimal) asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O $(ALIGN) -funroll-loops \ +# -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### Normal (non-asm) compilation CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ + -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 LIBNAME = libpng%N% PNGMAJ = 0 diff -ru4NwbB libpng-1.2.29/scripts/makefile.darwin libpng-1.2.30/scripts/makefile.darwin --- libpng-1.2.29/scripts/makefile.darwin 2008-05-08 06:58:09.846805979 -0500 +++ libpng-1.2.30/scripts/makefile.darwin 2008-08-15 09:14:44.898903507 -0500 @@ -1,6 +1,6 @@ # makefile for libpng on Darwin / Mac OS X -# Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 2001 Christoph Pfisterer # derived from makefile.linux: # Copyright (C) 1998, 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger @@ -17,9 +17,9 @@ ZLIBINC=../zlib # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = 12 PNGMIN = 1.2.30 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -37,10 +37,10 @@ LN_SF=ln -sf RANLIB=ranlib RM_F=/bin/rm -f -# CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE -CFLAGS=-I$(ZLIBINC) -Wall -O -funroll-loops +# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE +CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops LDFLAGS=-L. -L$(ZLIBLIB) -lpng%N% -lz INCPATH=$(prefix)/include LIBPATH=$(exec_prefix)/lib diff -ru4NwbB libpng-1.2.29/scripts/makefile.elf libpng-1.2.30/scripts/makefile.elf --- libpng-1.2.29/scripts/makefile.elf 2008-05-08 06:58:09.919402726 -0500 +++ libpng-1.2.30/scripts/makefile.elf 2008-08-15 09:14:44.918961612 -0500 @@ -1,6 +1,7 @@ # makefile for libpng.a and libpng%N%.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs +# and Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h # Modified for Debian by Junichi Uekawa and Josselin Mouette @@ -52,9 +53,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-Wall -D_REENTRANT -O2 \ +CFLAGS=-W -Wall -D_REENTRANT -O2 \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -lpng%N% LDFLAGS_A=libpng.a -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.gcc libpng-1.2.30/scripts/makefile.gcc --- libpng-1.2.29/scripts/makefile.gcc 2006-06-05 10:10:59.000000000 -0500 +++ libpng-1.2.30/scripts/makefile.gcc 2008-08-02 07:20:59.850809000 -0500 @@ -1,5 +1,6 @@ # makefile for libpng using gcc (generic, static library) +# Copyright (C) 2008 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h @@ -17,10 +18,10 @@ CDEBUG = -g -DPNG_DEBUG=5 LDDEBUG = CRELEASE = -O2 LDRELEASE = -s -#CFLAGS = -Wall $(CDEBUG) -CFLAGS = -Wall $(CRELEASE) +#CFLAGS = -W -Wall $(CDEBUG) +CFLAGS = -W -Wall $(CRELEASE) #LDFLAGS = $(LDDEBUG) LDFLAGS = $(LDRELEASE) LIBS = -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.gcmmx libpng-1.2.30/scripts/makefile.gcmmx --- libpng-1.2.29/scripts/makefile.gcmmx 2008-05-08 06:58:09.960060538 -0500 +++ libpng-1.2.30/scripts/makefile.gcmmx 2008-08-15 09:14:44.929346038 -0500 @@ -1,7 +1,7 @@ # makefile for libpng.a and libpng%N%.so on Linux ELF with gcc using MMX # assembler code -# Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright 2002, 2006, 2008 Greg Roelofs and Glenn Randers-Pehrson # Copyright 1998-2001 Greg Roelofs # Copyright 1996-1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -57,17 +57,17 @@ # for pgcc version 2.95.1, -O3 is buggy; don't use it. # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety ### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ $(ALIGN) -funroll-loops \ -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 ### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer ### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ # -m486 -malign-double -ffast-math \ # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.hpgcc libpng-1.2.30/scripts/makefile.hpgcc --- libpng-1.2.29/scripts/makefile.hpgcc 2008-05-08 06:58:10.031027279 -0500 +++ libpng-1.2.30/scripts/makefile.hpgcc 2008-08-15 09:14:44.948866056 -0500 @@ -1,6 +1,6 @@ # makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. -# Copyright (C) 2002, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006-2008 Glenn Randers-Pehrson # Copyright (C) 2001, Laurent faillie # Copyright (C) 1998, 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -52,9 +52,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 #LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS=-L. -L$(ZLIBLIB) -lpng%N% -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.linux libpng-1.2.30/scripts/makefile.linux --- libpng-1.2.29/scripts/makefile.linux 2008-05-08 06:58:10.101896849 -0500 +++ libpng-1.2.30/scripts/makefile.linux 2008-08-15 09:14:44.968610136 -0500 @@ -1,6 +1,7 @@ # makefile for libpng.a and libpng%N%.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs and +# Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h # Library name: @@ -46,9 +47,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.mingw libpng-1.2.30/scripts/makefile.mingw --- libpng-1.2.29/scripts/makefile.mingw 2008-05-08 06:58:10.144711589 -0500 +++ libpng-1.2.30/scripts/makefile.mingw 2008-08-15 09:14:44.979003045 -0500 @@ -3,9 +3,9 @@ # of the library, and builds two copies of pngtest: one # statically linked and one dynamically linked. # # Built from makefile.cygwin -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, +# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson, # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: # Copyright (C) 1998-2000, 2007 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -59,17 +59,17 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion ### if you don't need thread safety, but want the asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \ +# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### if you need thread safety and want (minimal) asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O $(ALIGN) -funroll-loops \ +# -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### Normal (non-asm) compilation CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ + -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 LIBNAME = libpng%N% PNGMAJ = 0 diff -ru4NwbB libpng-1.2.29/scripts/makefile.nommx libpng-1.2.30/scripts/makefile.nommx --- libpng-1.2.29/scripts/makefile.nommx 2008-05-08 06:58:10.216422864 -0500 +++ libpng-1.2.30/scripts/makefile.nommx 2008-08-15 09:14:45.006612895 -0500 @@ -1,6 +1,6 @@ # makefile for libpng.a and libpng%N%.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and +# Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and # Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -47,9 +47,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.openbsd libpng-1.2.30/scripts/makefile.openbsd --- libpng-1.2.29/scripts/makefile.openbsd 2008-05-08 06:58:10.237322126 -0500 +++ libpng-1.2.30/scripts/makefile.openbsd 2008-08-15 09:14:45.015557870 -0500 @@ -1,7 +1,7 @@ # makefile for libpng # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# Copyright (C) 2007 Glenn Randers-Pehrson +# Copyright (C) 2007-2008 Glenn Randers-Pehrson # For conditions of distribution and use, see copyright notice in png.h PREFIX?= /usr/local LIBDIR= ${PREFIX}/lib @@ -16,9 +16,9 @@ pngwio.c pngwrite.c pngwtran.c pngwutil.c HDRS= png.h pngconf.h -CFLAGS+= -Wall +CFLAGS+= -W -Wall CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE NOPROFILE= Yes diff -ru4NwbB libpng-1.2.29/scripts/makefile.os2 libpng-1.2.30/scripts/makefile.os2 --- libpng-1.2.29/scripts/makefile.os2 2001-01-05 18:25:05.000000000 -0600 +++ libpng-1.2.30/scripts/makefile.os2 2008-08-02 07:23:02.526620000 -0500 @@ -11,9 +11,9 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O6 -funroll-loops -malign-loops=2 \ -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll AR=emxomfar diff -ru4NwbB libpng-1.2.29/scripts/makefile.so9 libpng-1.2.30/scripts/makefile.so9 --- libpng-1.2.29/scripts/makefile.so9 2008-05-08 06:58:10.377947491 -0500 +++ libpng-1.2.30/scripts/makefile.so9 2008-08-15 09:14:45.054932476 -0500 @@ -1,8 +1,8 @@ # makefile for libpng on Solaris 9 (beta) with Forte cc # Updated by Chad Schrock for Solaris 9 # Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 1998-2001 Greg Roelofs # Copyright (C) 1996-1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -46,9 +46,9 @@ #WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE +#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng%N% -lz -lm INCPATH=$(prefix)/include diff -ru4NwbB libpng-1.2.29/scripts/makefile.solaris libpng-1.2.30/scripts/makefile.solaris --- libpng-1.2.29/scripts/makefile.solaris 2008-05-08 06:58:10.413830242 -0500 +++ libpng-1.2.30/scripts/makefile.solaris 2008-08-15 09:14:45.065052656 -0500 @@ -1,6 +1,6 @@ # makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson # Contributed by William L. Sebok, based on makefile.linux # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -42,9 +42,9 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O \ -DPNG_NO_MMX_CODE; \ # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng%N% -lz -lm diff -ru4NwbB libpng-1.2.29/scripts/makefile.solaris-x86 libpng-1.2.30/scripts/makefile.solaris-x86 --- libpng-1.2.29/scripts/makefile.solaris-x86 2008-05-08 06:58:10.450745327 -0500 +++ libpng-1.2.30/scripts/makefile.solaris-x86 2008-08-15 09:14:45.074918988 -0500 @@ -1,6 +1,6 @@ # makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson # Contributed by William L. Sebok, based on makefile.linux # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h @@ -42,9 +42,9 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O \ # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng%N% -lz -lm INCPATH=$(prefix)/include