[libpng17] Revert change to png_default_read_data() made in libpng-1.7.0beta55.
diff --git a/ANNOUNCE b/ANNOUNCE
index 710fa5e..2be6442 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.7.0beta57 - March 15, 2015
+Libpng 1.7.0beta57 - March 17, 2015
 
 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.
@@ -750,8 +750,12 @@
   Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
     for consistency, and remove some useless tests (Alexey Petruchik).
 
-Version 1.7.0beta57 [March 15, 2015]
-  Remove pnglibconf.h, not pnglibconf.* in "make clean" (Cosmin).
+Version 1.7.0beta57 [March 17, 2015]
+  Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of
+    pnglibconf.* in "make clean" (Cosmin).
+  Fix bug in calculation of maxbits, in png_write_sBIT, introduced
+    in libpng-1.6.17beta01 (John Bowler).
+  Revert change to png_default_read_data() made in libpng-1.7.0beta55.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index a8a16e9..3deaa54 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5040,8 +5040,12 @@
   Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
     for consistency, and remove some useless tests (Alexey Petruchik).
 
-Version 1.7.0beta57 [March 15, 2015]
-  Remove pnglibconf.h, not pnglibconf.* in "make clean" (Cosmin).
+Version 1.7.0beta57 [March 17, 2015]
+  Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of
+    pnglibconf.* in "make clean" (Cosmin).
+  Fix bug in calculation of maxbits, in png_write_sBIT, introduced
+    in libpng-1.6.17beta01 (John Bowler).
+  Revert change to png_default_read_data() made in libpng-1.7.0beta55.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/pngrio.c b/pngrio.c
index f33d8de..f30c768 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -49,42 +49,18 @@
 void PNGCBAPI
 png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
-   png_FILE_p io_ptr;
+   png_size_t check;
 
-   io_ptr = png_get_io_ptr(png_ptr);
+   if (png_ptr == NULL)
+      return;
 
-   if (length == 0)
-      png_error(png_ptr, "Read Error: invalid length requested");
-
-   clearerr(io_ptr);
-
-   if (fileno(io_ptr) == -1)
-      png_error(png_ptr, "Read Error: invalid io_ptr");
-
-   /*
-    * fread() returns 0 on error, so it is OK to store this in a png_size_t
+   /* fread() returns 0 on error, so it is OK to store this in a png_size_t
     * instead of an int, which is what fread() actually returns.
     */
-   if ((png_size_t)fread((void *)data, sizeof (png_byte), length,
-        io_ptr) != length)
-   {
-      clearerr(io_ptr);
-      png_error(png_ptr, "Read Error: invalid length returned");
-   }
+   check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
 
-   if (ferror(io_ptr))
-   {
-      clearerr(io_ptr);
-      png_error(png_ptr, "Read Error: error returned by fread()");
-   }
-
-   if (feof(io_ptr))
-   {
-      clearerr(io_ptr);
-      png_error(png_ptr, "Read Error: unexpected end of file");
-   }
-
-   clearerr(io_ptr);
+   if (check != length)
+      png_error(png_ptr, "Read Error");
 }
 #endif