libpng: Update to upstream version 1.6.32
Fixes security vulnerability in our 1.6.31rc01 snapshot.
This commit is contained in:
parent
73d2504fce
commit
ee1d0179c5
18 changed files with 234 additions and 88 deletions
2
thirdparty/README.md
vendored
2
thirdparty/README.md
vendored
|
@ -107,7 +107,7 @@ Files extracted from upstream source:
|
|||
## libpng
|
||||
|
||||
- Upstream: http://libpng.org/pub/png/libpng.html
|
||||
- Version: 1.6.31rc01
|
||||
- Version: 1.6.32
|
||||
- License: libpng/zlib
|
||||
|
||||
Files extracted from upstream source:
|
||||
|
|
2
thirdparty/libpng/arm/filter_neon.S
vendored
2
thirdparty/libpng/arm/filter_neon.S
vendored
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
|
22
thirdparty/libpng/png.c
vendored
22
thirdparty/libpng/png.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -14,7 +14,7 @@
|
|||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_31rc01 Your_png_h_is_not_version_1_6_31rc01;
|
||||
typedef png_libpng_version_1_6_32 Your_png_h_is_not_version_1_6_32;
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* The version tests may need to be added to, but the problem warning has
|
||||
|
@ -619,8 +619,18 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
/* Free any eXIf entry */
|
||||
if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->exif);
|
||||
info_ptr->exif = NULL;
|
||||
# ifdef PNG_READ_eXIf_SUPPORTED
|
||||
if (info_ptr->eXIf_buf)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
}
|
||||
# endif
|
||||
if (info_ptr->exif)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->exif);
|
||||
info_ptr->exif = NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_eXIf;
|
||||
}
|
||||
#endif
|
||||
|
@ -806,14 +816,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.31rc01 - July 19, 2017" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.32 - August 24, 2017" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
|
||||
PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE;
|
||||
# else
|
||||
return "libpng version 1.6.31rc01 - July 19, 2017\
|
||||
return "libpng version 1.6.32 - August 24, 2017\
|
||||
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
|
|
33
thirdparty/libpng/png.h
vendored
33
thirdparty/libpng/png.h
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.31rc01, July 19, 2017
|
||||
* libpng version 1.6.32, August 24, 2017
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -12,7 +12,7 @@
|
|||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.31rc01, July 19, 2017:
|
||||
* libpng versions 0.97, January 1998, through 1.6.32, August 24, 2017:
|
||||
* Glenn Randers-Pehrson.
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@
|
|||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.31rc01, July 19, 2017 are
|
||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, and are distributed according to the same
|
||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
|
@ -213,7 +213,7 @@
|
|||
* ...
|
||||
* 1.5.28 15 10527 15.so.15.28[.0]
|
||||
* ...
|
||||
* 1.6.31 16 10631 16.so.16.31[.0]
|
||||
* 1.6.32 16 10632 16.so.16.32[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -241,13 +241,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* July 19, 2017
|
||||
* August 24, 2017
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.6.31rc01 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.32 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
@ -309,8 +309,8 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.31rc01"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.31rc01 - July 19, 2017\n"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.32"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.32 - August 24, 2017\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
|
@ -318,13 +318,13 @@
|
|||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 31
|
||||
#define PNG_LIBPNG_VER_RELEASE 32
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 01
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
|
@ -341,7 +341,7 @@
|
|||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||
PNG_LIBPNG_BUILD_PRIVATE */
|
||||
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
|
@ -349,7 +349,7 @@
|
|||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10631 /* 1.6.31 */
|
||||
#define PNG_LIBPNG_VER 10632 /* 1.6.32 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -459,7 +459,7 @@ extern "C" {
|
|||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_31rc01;
|
||||
typedef char* png_libpng_version_1_6_32;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
@ -2014,6 +2014,11 @@ PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
|
|||
png_inforp info_ptr, png_bytep *exif));
|
||||
PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_bytep exif));
|
||||
|
||||
PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
|
||||
PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
|
@ -3259,7 +3264,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
|||
* one to use is one more than this.)
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(247);
|
||||
PNG_EXPORT_LAST_ORDINAL(249);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
2
thirdparty/libpng/pngconf.h
vendored
2
thirdparty/libpng/pngconf.h
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.31rc01, July 19, 2017
|
||||
* libpng version 1.6.32, August 24, 2017
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
|
2
thirdparty/libpng/pngerror.c
vendored
2
thirdparty/libpng/pngerror.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
|
15
thirdparty/libpng/pngget.c
vendored
15
thirdparty/libpng/pngget.c
vendored
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
|
@ -777,12 +777,23 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
png_uint_32 PNGAPI
|
||||
png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep *exif)
|
||||
{
|
||||
png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1");
|
||||
PNG_UNUSED(info_ptr)
|
||||
PNG_UNUSED(exif)
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 *num_exif, png_bytep *exif)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "eXIf");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL)
|
||||
{
|
||||
*num_exif = info_ptr->num_exif;
|
||||
*exif = info_ptr->exif;
|
||||
return (PNG_INFO_eXIf);
|
||||
}
|
||||
|
|
5
thirdparty/libpng/pnginfo.h
vendored
5
thirdparty/libpng/pnginfo.h
vendored
|
@ -186,8 +186,11 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
int num_exif;
|
||||
int num_exif; /* Added at libpng-1.6.31 */
|
||||
png_bytep exif;
|
||||
# ifdef PNG_READ_eXIf_SUPPORTED
|
||||
png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
|
|
4
thirdparty/libpng/pnglibconf.h
vendored
4
thirdparty/libpng/pnglibconf.h
vendored
|
@ -1,8 +1,8 @@
|
|||
/* libpng 1.6.31rc01 STANDARD API DEFINITION */
|
||||
/* libpng 1.6.32 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.6.31rc01 - July 19, 2017 */
|
||||
/* Libpng version 1.6.32 - August 24, 2017 */
|
||||
|
||||
/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
|
||||
|
||||
|
|
5
thirdparty/libpng/pngpread.c
vendored
5
thirdparty/libpng/pngpread.c
vendored
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
|
@ -189,6 +189,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_crc_read(png_ptr, chunk_tag, 4);
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
png_check_chunk_length(png_ptr, png_ptr->push_length);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
|
|
14
thirdparty/libpng/pngpriv.h
vendored
14
thirdparty/libpng/pngpriv.h
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -1143,6 +1143,11 @@ PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,
|
|||
int intent),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_eXIf_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr,
|
||||
png_bytep exif, int num_exif),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
|
||||
png_const_charp name, png_const_bytep profile), PNG_EMPTY);
|
||||
|
@ -1522,8 +1527,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
|||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,
|
||||
png_uint_32 chunk_name),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_name),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_length),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||
|
|
13
thirdparty/libpng/pngread.c
vendored
13
thirdparty/libpng/pngread.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -175,6 +175,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
else if (chunk_name == png_eXIf)
|
||||
png_handle_eXIf(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (chunk_name == png_gAMA)
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
|
@ -534,6 +539,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
png_error(png_ptr, "Invalid attempt to read row data");
|
||||
|
||||
/* Fill the row with IDAT data: */
|
||||
png_ptr->row_buf[0]=255; /* to force error if no data was found */
|
||||
png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
|
||||
|
@ -842,6 +848,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
else if (chunk_name == png_eXIf)
|
||||
png_handle_eXIf(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (chunk_name == png_gAMA)
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
|
|
2
thirdparty/libpng/pngrtran.c
vendored
2
thirdparty/libpng/pngrtran.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
|
143
thirdparty/libpng/pngrutil.c
vendored
143
thirdparty/libpng/pngrutil.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -181,6 +181,9 @@ png_read_chunk_header(png_structrp png_ptr)
|
|||
/* Check to see if chunk name is valid. */
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
/* Check for too-large chunk length */
|
||||
png_check_chunk_length(png_ptr, length);
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||
#endif
|
||||
|
@ -1377,11 +1380,13 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
* chunk is just ignored, so does not invalidate the color space. An
|
||||
* alternative is to set the 'invalid' flags at the start of this routine
|
||||
* and only clear them in they were not set before and all the tests pass.
|
||||
* The minimum 'deflate' stream is assumed to be just the 2 byte header and
|
||||
* 4 byte checksum. The keyword must be at least one character and there is
|
||||
* a terminator (0) byte and the compression method.
|
||||
*/
|
||||
if (length < 9)
|
||||
|
||||
/* The keyword must be at least one character and there is a
|
||||
* terminator (0) byte and the compression method byte, and the
|
||||
* 'zlib' datastream is at least 11 bytes.
|
||||
*/
|
||||
if (length < 14)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
|
@ -1413,6 +1418,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
png_crc_read(png_ptr, (png_bytep)keyword, read_length);
|
||||
length -= read_length;
|
||||
|
||||
/* The minimum 'zlib' stream is assumed to be just the 2 byte header,
|
||||
* 5 bytes minimum 'deflate' stream, and the 4 byte checksum.
|
||||
*/
|
||||
if (length < 11)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
return;
|
||||
}
|
||||
|
||||
keyword_length = 0;
|
||||
while (keyword_length < 80 && keyword_length < read_length &&
|
||||
keyword[keyword_length] != 0)
|
||||
|
@ -1431,7 +1446,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
|
||||
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
||||
{
|
||||
Byte profile_header[132];
|
||||
Byte profile_header[132]={0};
|
||||
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
||||
png_alloc_size_t size = (sizeof profile_header);
|
||||
|
||||
|
@ -2014,36 +2029,61 @@ void /* PRIVATE */
|
|||
png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
unsigned int i;
|
||||
png_bytep eXIf_buf;
|
||||
|
||||
png_debug(1, "in png_handle_eXIf");
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
png_chunk_error(png_ptr, "missing IHDR");
|
||||
|
||||
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
if (length < 2)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
return;
|
||||
}
|
||||
|
||||
else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "duplicate");
|
||||
return;
|
||||
}
|
||||
|
||||
eXIf_buf = png_voidcast(png_bytep,
|
||||
info_ptr->free_me |= PNG_FREE_EXIF;
|
||||
|
||||
info_ptr->eXIf_buf = png_voidcast(png_bytep,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->eXIf_buf == NULL)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
png_byte buf[1];
|
||||
png_crc_read(png_ptr, buf, 1);
|
||||
eXIf_buf[i] = buf[0];
|
||||
info_ptr->eXIf_buf[i] = buf[0];
|
||||
if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
|
||||
&& info_ptr->eXIf_buf[0] != buf[0])
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_crc_finish(png_ptr, 0) != 0)
|
||||
return;
|
||||
|
||||
info_ptr->num_exif = length;
|
||||
png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
|
||||
|
||||
png_set_eXIf(png_ptr, info_ptr, eXIf_buf);
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2624,23 +2664,28 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
{
|
||||
png_text text;
|
||||
|
||||
/* It worked; png_ptr->read_buffer now looks like a tEXt chunk except
|
||||
* for the extra compression type byte and the fact that it isn't
|
||||
* necessarily '\0' terminated.
|
||||
*/
|
||||
buffer = png_ptr->read_buffer;
|
||||
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
||||
if (png_ptr->read_buffer == NULL)
|
||||
errmsg="Read failure in png_handle_zTXt";
|
||||
else
|
||||
{
|
||||
/* It worked; png_ptr->read_buffer now looks like a tEXt chunk
|
||||
* except for the extra compression type byte and the fact that
|
||||
* it isn't necessarily '\0' terminated.
|
||||
*/
|
||||
buffer = png_ptr->read_buffer;
|
||||
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
||||
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.key = (png_charp)buffer;
|
||||
text.text = (png_charp)(buffer + keyword_length+2);
|
||||
text.text_length = uncompressed_length;
|
||||
text.itxt_length = 0;
|
||||
text.lang = NULL;
|
||||
text.lang_key = NULL;
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.key = (png_charp)buffer;
|
||||
text.text = (png_charp)(buffer + keyword_length+2);
|
||||
text.text_length = uncompressed_length;
|
||||
text.itxt_length = 0;
|
||||
text.lang = NULL;
|
||||
text.lang_key = NULL;
|
||||
|
||||
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
||||
errmsg = "insufficient memory";
|
||||
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
||||
errmsg = "insufficient memory";
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -3076,20 +3121,58 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
|||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name)
|
||||
png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||
{
|
||||
int i;
|
||||
png_uint_32 cn=chunk_name;
|
||||
|
||||
png_debug(1, "in png_check_chunk_name");
|
||||
|
||||
for (i=1; i<=4; ++i)
|
||||
{
|
||||
int c = chunk_name & 0xff;
|
||||
int c = cn & 0xff;
|
||||
|
||||
if (c < 65 || c > 122 || (c > 90 && c < 97))
|
||||
png_chunk_error(png_ptr, "invalid chunk type");
|
||||
|
||||
chunk_name >>= 8;
|
||||
cn >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
|
||||
{
|
||||
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
||||
|
||||
if (png_ptr->chunk_name != png_IDAT)
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
||||
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
|
||||
limit = PNG_USER_CHUNK_MALLOC_MAX;
|
||||
# endif
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t row_factor =
|
||||
(png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1)
|
||||
+ 1 + (png_ptr->interlaced? 6: 0));
|
||||
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
|
||||
limit=PNG_UINT_31_MAX;
|
||||
else
|
||||
limit = png_ptr->height * row_factor;
|
||||
limit += 6 + 5*(limit/32566+1); /* zlib+deflate overhead */
|
||||
limit=limit < PNG_UINT_31_MAX? limit : PNG_UINT_31_MAX;
|
||||
}
|
||||
|
||||
if (length > limit)
|
||||
{
|
||||
png_debug2(0," length = %lu, limit = %lu",
|
||||
(unsigned long)length,(unsigned long)limit);
|
||||
png_chunk_error(png_ptr, "chunk data is too large");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
thirdparty/libpng/pngset.c
vendored
23
thirdparty/libpng/pngset.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.30 [June 28, 2017]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2017 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.)
|
||||
|
@ -138,6 +138,15 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
|||
void PNGAPI
|
||||
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_bytep eXIf_buf)
|
||||
{
|
||||
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
|
||||
PNG_UNUSED(info_ptr)
|
||||
PNG_UNUSED(eXIf_buf)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_uint_32 num_exif, const png_bytep eXIf_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -146,7 +155,13 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0);
|
||||
if (info_ptr->exif)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->exif);
|
||||
info_ptr->exif = NULL;
|
||||
}
|
||||
|
||||
info_ptr->num_exif = num_exif;
|
||||
|
||||
info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
|
||||
info_ptr->num_exif));
|
||||
|
@ -154,13 +169,12 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->exif == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_EXIF;
|
||||
|
||||
for (i = 0; i < info_ptr->num_exif; i++)
|
||||
for (i = 0; i < (int) info_ptr->num_exif; i++)
|
||||
info_ptr->exif[i] = eXIf_buf[i];
|
||||
|
||||
info_ptr->valid |= PNG_INFO_eXIf;
|
||||
|
@ -1388,6 +1402,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
static PNG_CONST png_byte chunks_to_ignore[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
101, 88, 73, 102, '\0', /* eXIf */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
104, 73, 83, 84, '\0', /* hIST */
|
||||
105, 67, 67, 80, '\0', /* iCCP */
|
||||
|
|
5
thirdparty/libpng/pngstruct.h
vendored
5
thirdparty/libpng/pngstruct.h
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.28 [January 5, 2017]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -479,8 +479,5 @@ struct png_struct_def
|
|||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.6.31 */
|
||||
int num_exif;
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
|
13
thirdparty/libpng/pngwrite.c
vendored
13
thirdparty/libpng/pngwrite.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
|
@ -237,6 +237,11 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_eXIf_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_hIST) != 0)
|
||||
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
|
||||
|
@ -432,6 +437,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_eXIf_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
|
||||
#endif
|
||||
|
|
17
thirdparty/libpng/pngwutil.c
vendored
17
thirdparty/libpng/pngwutil.c
vendored
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
|
@ -1479,24 +1479,15 @@ void /* PRIVATE */
|
|||
png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif)
|
||||
{
|
||||
int i;
|
||||
png_byte buf[3];
|
||||
png_byte buf[1];
|
||||
|
||||
png_debug(1, "in png_write_eXIf");
|
||||
|
||||
if (num_exif > (int)png_ptr->num_exif)
|
||||
{
|
||||
png_debug2(3, "num_exif = %d, png_ptr->num_exif = %d", num_exif,
|
||||
png_ptr->num_exif);
|
||||
|
||||
png_warning(png_ptr, "Invalid number of exif bytes specified");
|
||||
return;
|
||||
}
|
||||
|
||||
png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif));
|
||||
|
||||
for (i = 0; i < num_exif; i++)
|
||||
{
|
||||
buf[i] = exif[i];
|
||||
buf[0] = exif[i];
|
||||
png_write_chunk_data(png_ptr, buf, (png_size_t)1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue