This is a patch file for "libpng" 1.6.37. "libpng" 1.6.37 omits some legacy functions and/or access to some internal functions, and this breaks various programs. This patch file restores the following func- tions and/or access to the functions: png_check_sig png_read_data png_set_dither png_set_gray_1_2_4_to_8 --- libpng-1.6.37.old/png.c +++ libpng-1.6.37/png.c @@ -36,6 +36,38 @@ #define GCC_STRICT_OVERFLOW 0 #endif +//-------------------------------------------------------------------- + +#ifdef PNG_READ_SUPPORTED +#undef png_check_sig + +int PNGAPI +png_check_sig (png_bytep sig, int num) +{ + return ((int) !png_sig_cmp (sig, (png_size_t) 0, (png_size_t) num)); +} +#endif + +/* Read the data from whatever input you are using. The default routine + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more then 64K on a 16 bit machine. + */ + +#ifdef PNG_READ_SUPPORTED +void PNGAPI +png_read_data (png_structp png_ptr, png_bytep data, png_size_t length) +{ + if (png_ptr->read_data_fn != NULL) + (*(png_ptr->read_data_fn)) (png_ptr, data, length); + else + png_error (png_ptr, "Call to NULL read function"); +} +#endif + +//-------------------------------------------------------------------- + /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another * stream we can set num_bytes = 8 so that libpng will not attempt to read --- libpng-1.6.37.old/png.h +++ libpng-1.6.37/png.h @@ -905,6 +905,12 @@ */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); +/* Restored access to legacy functions */ +PNG_EXPORT (2, int, png_check_sig, (png_bytep, int)); +PNG_EXPORT (1, void, png_set_gray_1_2_4_to_8, (png_structp)); +PNG_EXPORT (3, void, png_read_data, + (png_structp, png_bytep, png_size_t)); + /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or --- libpng-1.6.37.old/pngpriv.h +++ libpng-1.6.37/pngpriv.h @@ -1,4 +1,3 @@ - /* pngpriv.h - private declarations for use inside libpng * * Copyright (c) 2018-2019 Cosmin Truta @@ -1087,10 +1086,6 @@ PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), PNG_EMPTY); -/* Read data from whatever input you are using into the "data" buffer */ -PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data, - size_t length),PNG_EMPTY); - /* Read bytes into buf, and update png_ptr->crc */ PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf, png_uint_32 length),PNG_EMPTY); --- libpng-1.6.37.old/pngrio.c +++ libpng-1.6.37/pngrio.c @@ -1,4 +1,3 @@ - /* pngrio.c - functions for data input * * Copyright (c) 2018 Cosmin Truta @@ -21,25 +20,6 @@ #include "pngpriv.h" #ifdef PNG_READ_SUPPORTED - -/* Read the data from whatever input you are using. The default routine - * reads from a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered reads. This should never be asked - * to read more than 64K on a 16-bit machine. - */ -void /* PRIVATE */ -png_read_data(png_structrp png_ptr, png_bytep data, size_t length) -{ - png_debug1(4, "reading %d bytes", (int)length); - - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - - else - png_error(png_ptr, "Call to NULL read function"); -} - #ifdef PNG_STDIO_SUPPORTED /* This is the function that does the actual reading of data. If you are * not reading from a standard C stream, you should create a replacement --- libpng-1.6.37.old/pngrtran.c +++ libpng-1.6.37/pngrtran.c @@ -31,6 +31,16 @@ #ifdef PNG_READ_SUPPORTED +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +/* Deprecated as of libpng-1.2.9 */ + +void PNGAPI +png_set_gray_1_2_4_to_8 (png_structp png_ptr) +{ + if (png_ptr == NULL) return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)