< prev index next >

src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c

Print this page

        

*** 27,38 **** * This file is available under and governed by the GNU General Public * License version 2 only, as published by the Free Software Foundation. * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * ! * Last changed in libpng 1.6.19 [November 12, 2015] ! * Copyright (c) 1998-2015 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer --- 27,38 ---- * This file is available under and governed by the GNU General Public * License version 2 only, as published by the Free Software Foundation. * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * ! * Last changed in libpng 1.6.22 [May 26, 2016] ! * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer
*** 49,73 **** * ancillary chunk uses signed (two's complement) numbers. */ void PNGAPI png_save_uint_32(png_bytep buf, png_uint_32 i) { ! buf[0] = (png_byte)(i >> 24); ! buf[1] = (png_byte)(i >> 16); ! buf[2] = (png_byte)(i >> 8); ! buf[3] = (png_byte)(i ); } /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ void PNGAPI png_save_uint_16(png_bytep buf, unsigned int i) { ! buf[0] = (png_byte)(i >> 8); ! buf[1] = (png_byte)(i ); } #endif /* Simple function to write the signature. If we have already written * the magic bytes of the signature, or more likely, the PNG stream is --- 49,73 ---- * ancillary chunk uses signed (two's complement) numbers. */ void PNGAPI png_save_uint_32(png_bytep buf, png_uint_32 i) { ! buf[0] = (png_byte)((i >> 24) & 0xffU); ! buf[1] = (png_byte)((i >> 16) & 0xffU); ! buf[2] = (png_byte)((i >> 8) & 0xffU); ! buf[3] = (png_byte)( i & 0xffU); } /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ void PNGAPI png_save_uint_16(png_bytep buf, unsigned int i) { ! buf[0] = (png_byte)((i >> 8) & 0xffU); ! buf[1] = (png_byte)( i & 0xffU); } #endif /* Simple function to write the signature. If we have already written * the magic bytes of the signature, or more likely, the PNG stream is
*** 691,784 **** if (output_len > 0) png_error(png_ptr, "error writing ancillary chunked compressed data"); } #endif /* WRITE_COMPRESSED_TEXT */ - #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - /* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The 'new_key' buffer must be 80 characters in size (for the keyword plus a - * trailing '\0'). If this routine returns 0 then there was no keyword, or a - * valid one could not be generated, and the caller must png_error. - */ - static png_uint_32 - png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) - { - png_const_charp orig_key = key; - png_uint_32 key_len = 0; - int bad_character = 0; - int space = 1; - - png_debug(1, "in png_check_keyword"); - - if (key == NULL) - { - *new_key = 0; - return 0; - } - - while (*key && key_len < 79) - { - png_byte ch = (png_byte)*key++; - - if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) - *new_key++ = ch, ++key_len, space = 0; - - else if (space == 0) - { - /* A space or an invalid character when one wasn't seen immediately - * before; output just a space. - */ - *new_key++ = 32, ++key_len, space = 1; - - /* If the character was not a space then it is invalid. */ - if (ch != 32) - bad_character = ch; - } - - else if (bad_character == 0) - bad_character = ch; /* just skip it, record the first error */ - } - - if (key_len > 0 && space != 0) /* trailing space */ - { - --key_len, --new_key; - if (bad_character == 0) - bad_character = 32; - } - - /* Terminate the keyword */ - *new_key = 0; - - if (key_len == 0) - return 0; - - #ifdef PNG_WARNINGS_SUPPORTED - /* Try to only output one warning per keyword: */ - if (*key != 0) /* keyword too long */ - png_warning(png_ptr, "keyword truncated"); - - else if (bad_character != 0) - { - PNG_WARNING_PARAMETERS(p) - - png_warning_parameter(p, 1, orig_key); - png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); - - png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); - } - #endif /* WARNINGS */ - - return key_len; - } - #endif /* WRITE_TEXT || WRITE_pCAL || WRITE_iCCP || WRITE_sPLT */ - /* Write the IHDR chunk, and update the png_struct with the necessary * information. Note that the rest of this code depends upon this * information being correct. */ void /* PRIVATE */ --- 691,700 ----
< prev index next >