diff --git a/png.h b/png.h index 457c932e5..861e84b86 100644 --- a/png.h +++ b/png.h @@ -3204,9 +3204,12 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, #ifdef PNG_MIPS_MSA_API_SUPPORTED # define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ #endif -#define PNG_IGNORE_ADLER32 8 +#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED +# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */ +#endif #ifdef PNG_POWERPC_VSX_API_SUPPORTED -# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */ +# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions + * supported */ #endif #ifdef PNG_MIPS_MMI_API_SUPPORTED # define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */ diff --git a/pngrutil.c b/pngrutil.c index 068ab193a..f471215ab 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -421,8 +421,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; } -#if ZLIB_VERNUM >= 0x1290 && \ - defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) +#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) /* Turn off validation of the ADLER32 checksum in IDAT chunks */ ret = inflateValidate(&png_ptr->zstream, 0); diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index f4d14a252..739805d2d 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -385,6 +385,34 @@ option BENIGN_ERRORS option BENIGN_WRITE_ERRORS requires BENIGN_ERRORS disabled option BENIGN_READ_ERRORS requires BENIGN_ERRORS +# Adler32 checksum +# +# This option allows the check of the Adler32 checksum performed by zlib to +# be turned off for IDAT chunks (only). Unless this option is enabled and +# turned on (not the default even if enabled) a failed Adler32 at the end of the +# stream will result in a decompression (inflate) failure on read even though +# the entire image might have been read successfully. +# +# This option relies on an undocumented function 'inflateValidate' which is +# present in only some versions of zlib. If the function is not present in the +# zlib used with libpng code which uses -lpng is likely to fail to link or to +# launch in the case of a DLL. +# +# Therefore this option is currently disabled by default; it has to be turned on +# in pngusr.dfa and then the application program has to explicitly turn the +# functionality on by calling png_set_option. +# +# Furthermore the option is explicitly turned off here if the zlib version +# number is below that required - libpng wouldn't compile in that case if the +# option were turned on. +option DISABLE_ADLER32_CHECK requires READ enables SET_OPTION disabled + +# ZLIB_VERNUM must be used here, not PNG_ZLIB_VERNUM, because +# scripts/options.awk ends up putting this test adhead of the setting of +# PNG_ZLIB_VERNUM (apparently above, but not because of the two-pass processing) +@#if ZLIB_VERNUM < 0x1290 +@# define PNG_NO_DISABLE_ADLER32_CHECK +@#endif # Generic options - affect both read and write. diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 06ecdd669..06d60451c 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,3 +1,4 @@ +/* 1.6.41.git STANDARD API DEFINITION */ /* pnglibconf.h - library build configuration */ /* libpng version 1.6.41.git */ @@ -27,6 +28,7 @@ #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED +/*#undef PNG_DISABLE_ADLER32_CHECK_SUPPORTED*/ #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED