[libpng16] Allow fine grain control of unknown chunk APIs. This change allows

png_set_keep_unknown_chunks() to be turned off if not required and causes
both read and write to behave appropriately (on read this is only possible
if the user callback is used to handle unknown chunks).  The change
also removes the support for storing unknown chunks in the info_struct
if the only unknown handling enabled is via the callback, allowing libpng
to be configured with callback reading and none of the unnecessary code.
diff --git a/pngset.c b/pngset.c
index 7cd23ff..7defe77 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1111,6 +1111,29 @@
    if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0)
       return;
 
+   /* Check for the failure cases where support has been disabled at compile
+    * time.  This code is hardly ever compiled - it's here because
+    * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this
+    * code) but may be meaningless if the read or write handling of unknown
+    * chunks is not compiled in.
+    */
+#  if !(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
+      (defined PNG_READ_SUPPORTED)
+      if (png_ptr->mode & PNG_IS_READ_STRUCT)
+      {
+         png_app_error(png_ptr, "no unknown chunk support on read");
+         return;
+      }
+#  endif
+#  if !(defined PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
+      (defined PNG_WRITE_SUPPORTED)
+      if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
+      {
+         png_app_error(png_ptr, "no unknown chunk support on write");
+         return;
+      }
+#  endif
+
    /* Prior to 1.6.0 this code used png_malloc_warn, however this meant that
     * unknown critical chunks could be lost with just a warning resulting in
     * undefined behavior.  Changing to png_malloc fixes this by producing a