mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Warn about ADLER32 checksum mismatch instead of issuing png_error().
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
This commit is contained in:
parent
28de8bf6cd
commit
f911c1146a
8
ANNOUNCE
8
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.7.0beta84 - September 19, 2016
|
Libpng 1.7.0beta84 - September 26, 2016
|
||||||
|
|
||||||
This is not intended to be a public release. It will be replaced
|
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.
|
within a few weeks by a public version or by another test version.
|
||||||
@ -1396,13 +1396,17 @@ Version 1.7.0beta83 [July 23, 2016]
|
|||||||
in reading.
|
in reading.
|
||||||
Fixed debug test of output gamma.
|
Fixed debug test of output gamma.
|
||||||
|
|
||||||
Version 1.7.0beta84 [September 19, 2016]
|
Version 1.7.0beta84 [September 26, 2016]
|
||||||
Minor editing of INSTALL, (whitespace, added copyright line)
|
Minor editing of INSTALL, (whitespace, added copyright line)
|
||||||
Don't install pngcp; it conflicts with pngcp in the pngtools package.
|
Don't install pngcp; it conflicts with pngcp in the pngtools package.
|
||||||
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
|
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
|
||||||
bugfix by John Bowler).
|
bugfix by John Bowler).
|
||||||
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
|
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
|
||||||
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
|
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
|
||||||
|
If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
|
||||||
|
ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
|
||||||
|
Warn about ADLER32 checksum mismatch instead of issuing a png_error().
|
||||||
|
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
6
CHANGES
6
CHANGES
@ -5696,13 +5696,17 @@ Version 1.7.0beta83 [July 23, 2016]
|
|||||||
in reading.
|
in reading.
|
||||||
Fixed debug test of output gamma.
|
Fixed debug test of output gamma.
|
||||||
|
|
||||||
Version 1.7.0beta84 [September 19, 2016]
|
Version 1.7.0beta84 [September 26, 2016]
|
||||||
Minor editing of INSTALL, (whitespace, added copyright line)
|
Minor editing of INSTALL, (whitespace, added copyright line)
|
||||||
Don't install pngcp; it conflicts with pngcp in the pngtools package.
|
Don't install pngcp; it conflicts with pngcp in the pngtools package.
|
||||||
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
|
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
|
||||||
bugfix by John Bowler).
|
bugfix by John Bowler).
|
||||||
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
|
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
|
||||||
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
|
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
|
||||||
|
If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
|
||||||
|
ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
|
||||||
|
Warn about ADLER32 checksum mismatch instead of issuing a png_error().
|
||||||
|
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
98
pngrutil.c
98
pngrutil.c
@ -260,12 +260,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
* are minimal.
|
* are minimal.
|
||||||
*/
|
*/
|
||||||
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
|
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
|
||||||
# if PNG_RELEASE_BUILD
|
#if PNG_RELEASE_BUILD
|
||||||
png_chunk_warning(png_ptr, msg);
|
png_chunk_warning(png_ptr, msg);
|
||||||
png_ptr->zowner = 0;
|
png_ptr->zowner = 0;
|
||||||
# else
|
#else
|
||||||
png_chunk_error(png_ptr, msg);
|
png_chunk_error(png_ptr, msg);
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation note: unlike 'png_deflate_claim' this internal function
|
/* Implementation note: unlike 'png_deflate_claim' this internal function
|
||||||
@ -283,21 +283,17 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int ret; /* zlib return code */
|
int ret; /* zlib return code */
|
||||||
# if ZLIB_VERNUM >= 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
|
int window_bits = 0;
|
||||||
|
|
||||||
# if defined(PNG_SET_OPTION_SUPPORTED) && \
|
# if defined(PNG_SET_OPTION_SUPPORTED) && \
|
||||||
defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
||||||
int window_bits;
|
|
||||||
|
|
||||||
if (png_ptr->maximum_inflate_window)
|
if (png_ptr->maximum_inflate_window)
|
||||||
window_bits = 15;
|
window_bits = 15;
|
||||||
|
|
||||||
else
|
# endif
|
||||||
window_bits = 0;
|
#endif /* ZLIB_VERNUM >= 0x1240 */
|
||||||
# else
|
|
||||||
# define window_bits 0
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Initialize the alloc/free callbacks every time: */
|
/* Initialize the alloc/free callbacks every time: */
|
||||||
png_ptr->zstream.zalloc = png_zalloc;
|
png_ptr->zstream.zalloc = png_zalloc;
|
||||||
@ -317,22 +313,28 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
*/
|
*/
|
||||||
if (png_ptr->zstream.state != NULL)
|
if (png_ptr->zstream.state != NULL)
|
||||||
{
|
{
|
||||||
# if ZLIB_VERNUM < 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
ret = inflateReset(&png_ptr->zstream);
|
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
||||||
# else
|
#else
|
||||||
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
ret = inflateReset(&png_ptr->zstream);
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# if ZLIB_VERNUM < 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
ret = inflateInit(&png_ptr->zstream);
|
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
||||||
# else
|
#else
|
||||||
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
ret = inflateInit(&png_ptr->zstream);
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
|
/* Turn off validation of the ADLER32 checksum */
|
||||||
|
if (png_ptr->current_crc == crc_quiet_use)
|
||||||
|
ret = inflateReset2(&png_ptr->zstream, -window_bits);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ret == Z_OK && png_ptr->zstream.state != NULL)
|
if (ret == Z_OK && png_ptr->zstream.state != NULL)
|
||||||
{
|
{
|
||||||
png_ptr->zowner = owner;
|
png_ptr->zowner = owner;
|
||||||
@ -3770,24 +3772,38 @@ png_inflate_IDAT(png_structrp png_ptr, int finish,
|
|||||||
*/
|
*/
|
||||||
if (!png_ptr->zstream_error) /* first time */
|
if (!png_ptr->zstream_error) /* first time */
|
||||||
{
|
{
|
||||||
# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||||
switch (png_ptr->IDAT_error_action)
|
switch (png_ptr->IDAT_error_action)
|
||||||
{
|
{
|
||||||
case PNG_ERROR:
|
case PNG_ERROR:
|
||||||
|
if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20))
|
||||||
|
{
|
||||||
|
if (png_ptr->current_crc != crc_quiet_use)
|
||||||
|
png_chunk_warning(png_ptr, "ADLER32 checksum mismatch");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
png_chunk_error(png_ptr, png_ptr->zstream.msg);
|
png_chunk_error(png_ptr, png_ptr->zstream.msg);
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case PNG_WARN:
|
case PNG_WARN:
|
||||||
png_chunk_warning(png_ptr, png_ptr->zstream.msg);
|
png_chunk_warning(png_ptr, png_ptr->zstream.msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* ignore */
|
default: /* ignore */
|
||||||
/* Keep going */
|
/* Keep going */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
# else
|
#else
|
||||||
png_chunk_error(png_ptr, png_ptr->zstream.msg);
|
{
|
||||||
# endif /* !BENIGN_ERRORS */
|
if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20))
|
||||||
|
png_chunk_warning(png_ptr, "ADLER32 checksum mismatch");
|
||||||
|
else
|
||||||
|
png_chunk_error(png_ptr, png_ptr->zstream.msg);
|
||||||
|
}
|
||||||
|
#endif /* !BENIGN_ERRORS */
|
||||||
|
|
||||||
/* And prevent the report about too many IDATs on streams with internal
|
/* And prevent the report about too many IDATs on streams with internal
|
||||||
* LZ errors:
|
* LZ errors:
|
||||||
|
@ -986,9 +986,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
/* Allow application (pngtest) errors and warnings to pass */
|
/* Allow application (pngtest) errors and warnings to pass */
|
||||||
png_set_benign_errors(read_ptr, 1);
|
png_set_benign_errors(read_ptr, 1);
|
||||||
|
|
||||||
|
/* Turn off CRC and ADLER32 checking while reading */
|
||||||
|
png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
|
||||||
|
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
png_set_benign_errors(write_ptr, 1);
|
png_set_benign_errors(write_ptr, 1);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* BENIGN_ERRORS */
|
#endif /* BENIGN_ERRORS */
|
||||||
|
|
||||||
|
BIN
tests/badadler.png
Normal file
BIN
tests/badadler.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 B |
BIN
tests/badcrc.png
Normal file
BIN
tests/badcrc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 B |
@ -1,2 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
./pngtest --relaxed ${srcdir}/tests/badcrc.png
|
||||||
|
./pngtest --relaxed ${srcdir}/tests/badadler.png
|
||||||
exec ./pngtest --strict ${srcdir}/pngtest.png
|
exec ./pngtest --strict ${srcdir}/pngtest.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user