提交 96b91705 编写于 作者: G Glenn Randers-Pehrson

[libpng16] Revised png_set_keep_unknown_chunks() so num_chunks < 0 means

ignore all unknown chunks and all known chunks except for IHDR, PLTE, tRNS,
IDAT, and IEND.  Previously it only meant ignore all unknown chunks, the
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
provide a list of chunks to be processed instead of a list of chunks to
ignore.  Revised contrib/gregbook/readpng2.c accordingly.
上级 0546e4e5
Libpng 1.6.0beta25 - June 12, 2012 Libpng 1.6.0beta25 - June 16, 2012
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
...@@ -385,7 +385,13 @@ Version 1.6.0beta23 [June 6, 2012] ...@@ -385,7 +385,13 @@ Version 1.6.0beta23 [June 6, 2012]
Version 1.6.0beta24 [June 7, 2012] Version 1.6.0beta24 [June 7, 2012]
Don't check palette indexes if num_palette is 0 (as it can be in MNG files). Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
Version 1.6.0beta25 [June 12, 2012] Version 1.6.0beta25 [June 16, 2012]
Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
and IEND. Previously it only meant ignore all unknown chunks, the
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
provide a list of chunks to be processed instead of a list of chunks to
ignore. Revised contrib/gregbook/readpng2.c accordingly.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
......
...@@ -4136,7 +4136,13 @@ Version 1.6.0beta23 [June 6, 2012] ...@@ -4136,7 +4136,13 @@ Version 1.6.0beta23 [June 6, 2012]
Version 1.6.0beta24 [June 7, 2012] Version 1.6.0beta24 [June 7, 2012]
Don't check palette indexes if num_palette is 0 (as it can be in MNG files). Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
Version 1.6.0beta25 [June 12, 2012] Version 1.6.0beta25 [June 16, 2012]
Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
and IEND. Previously it only meant ignore all unknown chunks, the
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
provide a list of chunks to be processed instead of a list of chunks to
ignore. Revised contrib/gregbook/readpng2.c accordingly.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
......
...@@ -136,29 +136,23 @@ int readpng2_init(mainprog_info *mainprog_ptr) ...@@ -136,29 +136,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT, * used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */ * IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
{ {
/* These byte strings were copied from png.h. If a future libpng /* These byte strings were copied from png.h. If a future version
* version recognizes more chunks, add them to this list. If a * of readpng2.c recognizes more chunks, add them to this list.
* future version of readpng2.c recognizes more chunks, delete them */
* from this list. */ static PNG_CONST png_byte chunks_to_process[] = {
static /* const */ png_byte chunks_to_ignore[] = { 98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */ 103, 65, 77, 65, '\0', /* gAMA */
104, 73, 83, 84, '\0', /* hIST */ 115, 82, 71, 66, '\0', /* sRGB */
105, 67, 67, 80, '\0', /* iCCP */ };
105, 84, 88, 116, '\0', /* iTXt */
111, 70, 70, 115, '\0', /* oFFs */ /* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
112, 67, 65, 76, '\0', /* pCAL */ png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
112, 72, 89, 115, '\0', /* pHYs */ NULL, -1);
115, 66, 73, 84, '\0', /* sBIT */
115, 67, 65, 76, '\0', /* sCAL */ /* But do not ignore chunks in the "chunks_to_process" list */
115, 80, 76, 84, '\0', /* sPLT */ png_set_keep_unknown_chunks(png_ptr,
115, 84, 69, 82, '\0', /* sTER */ 0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
116, 69, 88, 116, '\0', /* tEXt */ sizeof(chunks_to_process)/5);
116, 73, 77, 69, '\0', /* tIME */
122, 84, 88, 116, '\0' /* zTXt */
};
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
} }
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */ #endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
......
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.0beta25 - June 12, 2012 libpng version 1.6.0beta25 - June 16, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
...@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng ...@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.0beta25 - June 12, 2012 libpng versions 0.97, January 1998, through 1.6.0beta25 - June 16, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
...@@ -572,6 +572,7 @@ chunk types. To change this, you can call: ...@@ -572,6 +572,7 @@ chunk types. To change this, you can call:
png_set_keep_unknown_chunks(png_ptr, keep, png_set_keep_unknown_chunks(png_ptr, keep,
chunk_list, num_chunks); chunk_list, num_chunks);
keep - 0: default unknown chunk handling keep - 0: default unknown chunk handling
1: ignore; do not keep 1: ignore; do not keep
2: keep only if safe-to-copy 2: keep only if safe-to-copy
...@@ -585,11 +586,16 @@ chunk types. To change this, you can call: ...@@ -585,11 +586,16 @@ chunk types. To change this, you can call:
chunk_list - list of chunks affected (a byte string, chunk_list - list of chunks affected (a byte string,
five bytes per chunk, NULL or '\0' if five bytes per chunk, NULL or '\0' if
num_chunks is 0) num_chunks is positive; ignored if
numchunks <= 0).
num_chunks - number of chunks affected; if 0, all num_chunks - number of chunks affected; if 0, all
unknown chunks are affected. If nonzero, unknown chunks are affected. If positive,
only the chunks in the list are affected only the chunks in the list are affected,
and if negative all unknown chunks and
all known chunks except for the IHDR,
PLTE, tRNS, IDAT, and IEND chunks are
affected.
Unknown chunks declared in this way will be saved as raw data onto a Unknown chunks declared in this way will be saved as raw data onto a
list of png_unknown_chunk structures. If a chunk that is normally list of png_unknown_chunk structures. If a chunk that is normally
...@@ -5013,7 +5019,7 @@ Other rules can be inferred by inspecting the libpng source. ...@@ -5013,7 +5019,7 @@ Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng XVI. Y2K Compliance in libpng
June 12, 2012 June 16, 2012
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
...@@ -5022,16 +5028,16 @@ This is your unofficial assurance that libpng from version 0.71 and ...@@ -5022,16 +5028,16 @@ This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.0beta25 are Y2K compliant. It is my belief that earlier upward through 1.6.0beta25 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that Libpng only has two year fields. One is a 2-byte unsigned integer
will hold years up to 65535. The other two hold the date in text that will hold years up to 65535. The other, which is deprecated,
format, and will hold years up to 9999. holds the date in text format, and will hold years up to 9999.
The integer is The integer is
"png_uint_16 year" in png_time_struct. "png_uint_16 year" in png_time_struct.
The strings are The string is
"png_charp time_buffer" in png_struct and "char time_buffer[29]" in png_struct. This is no longer used
"near_time_buffer", which is a local character string in png.c. in libpng-1.6.x and will be removed from libpng-1.7.0.
There are seven time-related functions: There are seven time-related functions:
......
.TH LIBPNG 3 "June 12, 2012" .TH LIBPNG 3 "June 16, 2012"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta25 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta25
.SH SYNOPSIS .SH SYNOPSIS
...@@ -1007,7 +1007,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. ...@@ -1007,7 +1007,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.0beta25 - June 12, 2012 libpng version 1.6.0beta25 - June 16, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
...@@ -1018,7 +1018,7 @@ libpng-manual.txt - A description on how to use and modify libpng ...@@ -1018,7 +1018,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.0beta25 - June 12, 2012 libpng versions 0.97, January 1998, through 1.6.0beta25 - June 16, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
...@@ -1579,6 +1579,7 @@ chunk types. To change this, you can call: ...@@ -1579,6 +1579,7 @@ chunk types. To change this, you can call:
png_set_keep_unknown_chunks(png_ptr, keep, png_set_keep_unknown_chunks(png_ptr, keep,
chunk_list, num_chunks); chunk_list, num_chunks);
keep - 0: default unknown chunk handling keep - 0: default unknown chunk handling
1: ignore; do not keep 1: ignore; do not keep
2: keep only if safe-to-copy 2: keep only if safe-to-copy
...@@ -1592,11 +1593,16 @@ chunk types. To change this, you can call: ...@@ -1592,11 +1593,16 @@ chunk types. To change this, you can call:
chunk_list - list of chunks affected (a byte string, chunk_list - list of chunks affected (a byte string,
five bytes per chunk, NULL or '\0' if five bytes per chunk, NULL or '\0' if
num_chunks is 0) num_chunks is positive; ignored if
numchunks <= 0).
num_chunks - number of chunks affected; if 0, all num_chunks - number of chunks affected; if 0, all
unknown chunks are affected. If nonzero, unknown chunks are affected. If positive,
only the chunks in the list are affected only the chunks in the list are affected,
and if negative all unknown chunks and
all known chunks except for the IHDR,
PLTE, tRNS, IDAT, and IEND chunks are
affected.
Unknown chunks declared in this way will be saved as raw data onto a Unknown chunks declared in this way will be saved as raw data onto a
list of png_unknown_chunk structures. If a chunk that is normally list of png_unknown_chunk structures. If a chunk that is normally
...@@ -6021,7 +6027,7 @@ Other rules can be inferred by inspecting the libpng source. ...@@ -6021,7 +6027,7 @@ Other rules can be inferred by inspecting the libpng source.
.SH XVI. Y2K Compliance in libpng .SH XVI. Y2K Compliance in libpng
June 12, 2012 June 16, 2012
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
...@@ -6030,16 +6036,16 @@ This is your unofficial assurance that libpng from version 0.71 and ...@@ -6030,16 +6036,16 @@ This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.0beta25 are Y2K compliant. It is my belief that earlier upward through 1.6.0beta25 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that Libpng only has two year fields. One is a 2-byte unsigned integer
will hold years up to 65535. The other two hold the date in text that will hold years up to 65535. The other, which is deprecated,
format, and will hold years up to 9999. holds the date in text format, and will hold years up to 9999.
The integer is The integer is
"png_uint_16 year" in png_time_struct. "png_uint_16 year" in png_time_struct.
The strings are The string is
"png_charp time_buffer" in png_struct and "char time_buffer[29]" in png_struct. This is no longer used
"near_time_buffer", which is a local character string in png.c. in libpng-1.6.x and will be removed from libpng-1.7.0.
There are seven time-related functions: There are seven time-related functions:
...@@ -6289,7 +6295,7 @@ possible without all of you. ...@@ -6289,7 +6295,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation. Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.0beta25 - June 12, 2012: Libpng version 1.6.0beta25 - June 16, 2012:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
...@@ -6312,7 +6318,7 @@ this sentence. ...@@ -6312,7 +6318,7 @@ this sentence.
This code is released under the libpng license. This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta25, June 12, 2012, are libpng versions 1.2.6, August 15, 2004, through 1.6.0beta25, June 16, 2012, are
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5 distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors with the following individual added to the list of Contributing Authors
...@@ -6411,7 +6417,7 @@ certification mark of the Open Source Initiative. ...@@ -6411,7 +6417,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
June 12, 2012 June 16, 2012
.\" end of man page .\" end of man page
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.6.0beta25 - June 12, 2012 * libpng version 1.6.0beta25 - June 16, 2012
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.0beta25 - June 12, 2012: Glenn * libpng versions 0.97, January 1998, through 1.6.0beta25 - June 16, 2012: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta25, June 12, 2012, are * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta25, June 16, 2012, are
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
...@@ -310,7 +310,7 @@ ...@@ -310,7 +310,7 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* June 12, 2012 * June 16, 2012
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
...@@ -320,14 +320,15 @@ ...@@ -320,14 +320,15 @@
* earlier versions were also Y2K compliant. * earlier versions were also Y2K compliant.
* *
* Libpng only has two year fields. One is a 2-byte unsigned integer * Libpng only has two year fields. One is a 2-byte unsigned integer
* that will hold years up to 65535. The other holds the date in text * that will hold years up to 65535. The other, which is deprecated,
* format, and will hold years up to 9999. * holds the date in text format, and will hold years up to 9999.
* *
* The integer is * The integer is
* "png_uint_16 year" in png_time_struct. * "png_uint_16 year" in png_time_struct.
* *
* The string is * The string is
* "png_char time_buffer" in png_struct * "char time_buffer[29]" in png_struct. This is no longer used
* in libpng-1.6.x and will be removed from libpng-1.7.0.
* *
* There are seven time-related functions: * There are seven time-related functions:
* png.c: png_convert_to_rfc_1123_buffer() in png.c * png.c: png_convert_to_rfc_1123_buffer() in png.c
...@@ -377,7 +378,7 @@ ...@@ -377,7 +378,7 @@
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.0beta25" #define PNG_LIBPNG_VER_STRING "1.6.0beta25"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.0beta25 - June 12, 2012\n" " libpng version 1.6.0beta25 - June 16, 2012\n"
#define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16 #define PNG_LIBPNG_VER_DLLNUM 16
...@@ -2318,15 +2319,22 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, ...@@ -2318,15 +2319,22 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
/* Provide a list of chunks and how they are to be handled, if the built-in /* Provide a list of chunks and how they are to be handled, if the built-in
handling or default unknown chunk handling is not desired. Any chunks not * handling or default unknown chunk handling is not desired. Any chunks not
listed will be handled in the default manner. The IHDR and IEND chunks * listed will be handled in the default manner. The IHDR and IEND chunks
must not be listed. Because this turns off the default handling for chunks * must not be listed. Because this turns off the default handling for chunks
that would otherwise be recognized the behavior of libpng transformations may * that would otherwise be recognized the behavior of libpng transformations may
well become incorrect! * well become incorrect!
keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior * keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior
= 1: PNG_HANDLE_CHUNK_NEVER: do not keep * = 1: PNG_HANDLE_CHUNK_NEVER: do not keep
= 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy * = 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy
= 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy * = 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy
* If num_chunks is 0, then the "keep" parameter specifies the default
* manner for handling unknown chunks. If num_chunks is positive, then
* the "keep" parameter specifies the manner for handling only those chunks
* appearing in the chunk_list array. If it is negative, then the "keep"
* parameter specifies the manner for handling all unknown chunks plus
* all chunks recognized by libpng except for the IHDR, PLTE, tRNS, IDAT,
* and IEND chunks.
*/ */
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
int keep, png_const_bytep chunk_list, int num_chunks)); int keep, png_const_bytep chunk_list, int num_chunks));
......
...@@ -1462,31 +1462,26 @@ png_image_skip_unused_chunks(png_structrp png_ptr) ...@@ -1462,31 +1462,26 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* *
* This provides a small performance improvement and eliminates any * This provides a small performance improvement and eliminates any
* potential vulnerability to security problems in the unused chunks. * potential vulnerability to security problems in the unused chunks.
*
* TODO: make it so that this is an explicit list to process, not a list
* to ignore?
*/ */
{ {
static PNG_CONST png_byte chunks_to_ignore[] = { static PNG_CONST png_byte chunks_to_process[] = {
104, 73, 83, 84, '\0', /* hIST */ 98, 75, 71, 68, '\0', /* bKGD */
105, 84, 88, 116, '\0', /* iTXt */ 99, 72, 82, 77, '\0', /* cHRM */
111, 70, 70, 115, '\0', /* oFFs */ 103, 65, 77, 65, '\0', /* gAMA */
112, 67, 65, 76, '\0', /* pCAL */ 105, 67, 67, 80, '\0', /* iCCP */
112, 72, 89, 115, '\0', /* pHYs */ 115, 66, 73, 84, '\0', /* sBIT */
115, 67, 65, 76, '\0', /* sCAL */ 115, 82, 71, 66, '\0', /* sRGB */
115, 80, 76, 84, '\0', /* sPLT */ };
116, 69, 88, 116, '\0', /* tEXt */
116, 73, 77, 69, '\0', /* tIME */ /* Ignore unknown chunks and all other chunks except for the
122, 84, 88, 116, '\0' /* zTXt */ * IHDR, PLTE, tRNS, IDAT, and IEND chunks.
}; */
/* Ignore unknown chunks */
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */, png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
NULL, 0); NULL, -1);
/* Ignore known but unused chunks */ /* But do not ignore image data handling chunks */
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */, png_set_keep_unknown_chunks(png_ptr, 0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */,
chunks_to_ignore, (sizeof chunks_to_ignore)/5); chunks_to_process, (sizeof chunks_to_process)/5);
} }
} }
......
...@@ -1183,14 +1183,44 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, ...@@ -1183,14 +1183,44 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
else else
png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
return; if (num_chunksIn == 0)
return;
} }
if (num_chunksIn < 0)
{
/* Ignore all unknown chunks and all chunks recognized by
* libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
*/
static PNG_CONST png_byte chunks_to_ignore[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
103, 65, 77, 65, '\0', /* gAMA */
104, 73, 83, 84, '\0', /* hIST */
105, 67, 67, 80, '\0', /* iCCP */
105, 84, 88, 116, '\0', /* iTXt */
111, 70, 70, 115, '\0', /* oFFs */
112, 67, 65, 76, '\0', /* pCAL */
112, 72, 89, 115, '\0', /* pHYs */
115, 66, 73, 84, '\0', /* sBIT */
115, 67, 65, 76, '\0', /* sCAL */
115, 80, 76, 84, '\0', /* sPLT */
115, 84, 69, 82, '\0', /* sTER */
115, 82, 71, 66, '\0', /* sRGB */
116, 69, 88, 116, '\0', /* tEXt */
116, 73, 77, 69, '\0', /* tIME */
122, 84, 88, 116, '\0' /* zTXt */
};
chunk_list = chunks_to_ignore;
num_chunks = (unsigned int) sizeof(chunks_to_ignore)/5;
}
if (chunk_list == NULL) if (chunk_list == NULL)
return; return;
/* The argument is >0 */ if (num_chunksIn > 0)
num_chunks = (unsigned int)num_chunksIn; num_chunks = (unsigned int)num_chunksIn;
old_num_chunks = png_ptr->num_chunk_list; old_num_chunks = png_ptr->num_chunk_list;
new_list = png_voidcast(png_bytep, png_malloc(png_ptr, new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册