summaryrefslogtreecommitdiff
path: root/pngread.c
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2011-11-16 12:04:39 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2011-11-16 12:04:39 -0600
commit89c2f842879fe815765058b9289e497b461d77b3 (patch)
treeeab6b2f96c9537b16951be8e39922c275a7d1b7a /pngread.c
parented9f84475db98cfd87d561dc4a756a0c3d4cc56f (diff)
downloadlibpng-89c2f842879fe815765058b9289e497b461d77b3.tar.gz
[libpng15] Fix Windows builds, add pngstest to Visual Studio and OpenWatcom
Diffstat (limited to 'pngread.c')
-rw-r--r--pngread.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/pngread.c b/pngread.c
index 3d33f4ee9..e2df70092 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1342,44 +1342,6 @@ png_image_read_init(png_imagep image)
image->opaque = control;
return 1;
-
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- /* Prepare the reader to ignore all recognized chunks whose
- * data will not be used, i.e., all chunks recognized by libpng
- * except for IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, cHRM,
- * and sRGB.
- *
- * This provides a small performance improvement and eliminates
- * any potential vulnerability to security problems in the unused
- * chunks)
- */
- {
- static /* const */ png_byte chunks_to_ignore[] = {
- 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 */
- 116, 69, 88, 116, '\0', /* tEXt */
- 116, 73, 77, 69, '\0', /* tIME */
- 122, 84, 88, 116, '\0' /* zTXt */
- };
-
- /* Ignore unknown chunks */
- png_set_keep_unknown_chunks(png_ptr,
- 1 /* PNG_HANDLE_CHUNK_NEVER */,
- NULL, 0);
-
- /* Ignore known but unused chunks */
- 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 */
}
/* Error clean up */
@@ -1944,6 +1906,47 @@ png_image_read_end(png_voidp argument)
png_error(png_ptr, "png_read_image: unsupported transformation");
}
+# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+ /* Prepare the reader to ignore all recognized chunks whose data will not
+ * be used, i.e., all chunks recognized by libpng except for those
+ * involved in basic image reading:
+ *
+ * IHDR, PLTE, IDAT, IEND
+ *
+ * Or image data handling:
+ *
+ * tRNS, bKGD, gAMA, cHRM, sRGB, iCCP and sBIT.
+ *
+ * This provides a small performance improvement and eliminates any
+ * 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[] = {
+ 104, 73, 83, 84, '\0', /* hIST */
+ 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, 67, 65, 76, '\0', /* sCAL */
+ 115, 80, 76, 84, '\0', /* sPLT */
+ 116, 69, 88, 116, '\0', /* tEXt */
+ 116, 73, 77, 69, '\0', /* tIME */
+ 122, 84, 88, 116, '\0' /* zTXt */
+ };
+
+ /* Ignore unknown chunks */
+ png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
+ NULL, 0);
+
+ /* Ignore known but unused chunks */
+ 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 */
+
/* Update the 'info' structure and make sure the result is as required; first
* make sure to turn on the interlace handling if it will be required
* (because it can't be turned on *after* the call to png_read_update_info!)