< prev index next >

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

Print this page




  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /* pngpread.c - read a png file in push mode
  26  *
  27  * This file is available under and governed by the GNU General Public
  28  * License version 2 only, as published by the Free Software Foundation.
  29  * However, the following notice accompanied the original version of this
  30  * file and, per its terms, should not be removed:
  31  *
  32  * Last changed in libpng 1.6.24 [August 4, 2016]
  33  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  34  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  35  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  36  *
  37  * This code is released under the libpng license.
  38  * For conditions of distribution and use, see the disclaimer
  39  * and license in png.h
  40  */
  41 
  42 #include "pngpriv.h"
  43 
  44 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  45 
  46 /* Push model modes */
  47 #define PNG_READ_SIG_MODE   0
  48 #define PNG_READ_CHUNK_MODE 1
  49 #define PNG_READ_IDAT_MODE  2
  50 #define PNG_READ_tEXt_MODE  4
  51 #define PNG_READ_zTXt_MODE  5
  52 #define PNG_READ_DONE_MODE  6
  53 #define PNG_READ_iTXt_MODE  7


 200 #endif
 201 
 202    /* First we make sure we have enough data for the 4-byte chunk name
 203     * and the 4-byte chunk length before proceeding with decoding the
 204     * chunk data.  To fully decode each of these chunks, we also make
 205     * sure we have enough data in the buffer for the 4-byte CRC at the
 206     * end of every chunk (except IDAT, which is handled separately).
 207     */
 208    if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
 209    {
 210       png_byte chunk_length[4];
 211       png_byte chunk_tag[4];
 212 
 213       PNG_PUSH_SAVE_BUFFER_IF_LT(8)
 214       png_push_fill_buffer(png_ptr, chunk_length, 4);
 215       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
 216       png_reset_crc(png_ptr);
 217       png_crc_read(png_ptr, chunk_tag, 4);
 218       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
 219       png_check_chunk_name(png_ptr, png_ptr->chunk_name);

 220       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
 221    }
 222 
 223    chunk_name = png_ptr->chunk_name;
 224 
 225    if (chunk_name == png_IDAT)
 226    {
 227       if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
 228          png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
 229 
 230       /* If we reach an IDAT chunk, this means we have read all of the
 231        * header chunks, and we can start reading the image (or if this
 232        * is called after the image has been read - we have an error).
 233        */
 234       if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
 235          png_error(png_ptr, "Missing IHDR before IDAT");
 236 
 237       else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
 238           (png_ptr->mode & PNG_HAVE_PLTE) == 0)
 239          png_error(png_ptr, "Missing PLTE before IDAT");




  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 /* pngpread.c - read a png file in push mode
  26  *
  27  * This file is available under and governed by the GNU General Public
  28  * License version 2 only, as published by the Free Software Foundation.
  29  * However, the following notice accompanied the original version of this
  30  * file and, per its terms, should not be removed:
  31  *
  32  * Last changed in libpng 1.6.32 [August 24, 2017]
  33  * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
  34  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  35  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  36  *
  37  * This code is released under the libpng license.
  38  * For conditions of distribution and use, see the disclaimer
  39  * and license in png.h
  40  */
  41 
  42 #include "pngpriv.h"
  43 
  44 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  45 
  46 /* Push model modes */
  47 #define PNG_READ_SIG_MODE   0
  48 #define PNG_READ_CHUNK_MODE 1
  49 #define PNG_READ_IDAT_MODE  2
  50 #define PNG_READ_tEXt_MODE  4
  51 #define PNG_READ_zTXt_MODE  5
  52 #define PNG_READ_DONE_MODE  6
  53 #define PNG_READ_iTXt_MODE  7


 200 #endif
 201 
 202    /* First we make sure we have enough data for the 4-byte chunk name
 203     * and the 4-byte chunk length before proceeding with decoding the
 204     * chunk data.  To fully decode each of these chunks, we also make
 205     * sure we have enough data in the buffer for the 4-byte CRC at the
 206     * end of every chunk (except IDAT, which is handled separately).
 207     */
 208    if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
 209    {
 210       png_byte chunk_length[4];
 211       png_byte chunk_tag[4];
 212 
 213       PNG_PUSH_SAVE_BUFFER_IF_LT(8)
 214       png_push_fill_buffer(png_ptr, chunk_length, 4);
 215       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
 216       png_reset_crc(png_ptr);
 217       png_crc_read(png_ptr, chunk_tag, 4);
 218       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
 219       png_check_chunk_name(png_ptr, png_ptr->chunk_name);
 220       png_check_chunk_length(png_ptr, png_ptr->push_length);
 221       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
 222    }
 223 
 224    chunk_name = png_ptr->chunk_name;
 225 
 226    if (chunk_name == png_IDAT)
 227    {
 228       if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
 229          png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
 230 
 231       /* If we reach an IDAT chunk, this means we have read all of the
 232        * header chunks, and we can start reading the image (or if this
 233        * is called after the image has been read - we have an error).
 234        */
 235       if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
 236          png_error(png_ptr, "Missing IHDR before IDAT");
 237 
 238       else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
 239           (png_ptr->mode & PNG_HAVE_PLTE) == 0)
 240          png_error(png_ptr, "Missing PLTE before IDAT");


< prev index next >