[libpng17] Merge recent changes from libpng-1.6.14beta06:

Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
Removed unused "text_len" parameter from private function png_write_zTXt().
Conditionally compile some code in png_deflate_claim(), when
  PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
  to pnglibconf.dfa.
Edit and fix typos in comments.
This commit is contained in:
Glenn Randers-Pehrson
2014-10-04 12:41:26 -05:00
parent b2e89f1af6
commit c7e743d385
10 changed files with 87 additions and 193 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.7.0beta38 - September 28, 2014 Libpng 1.7.0beta38 - October 4, 2014
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.
@@ -602,7 +602,14 @@ Version 1.7.0beta36 [September 27, 2014]
Version 1.7.0beta37 [September 28, 2014] Version 1.7.0beta37 [September 28, 2014]
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04. Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
Version 1.7.0beta38 [September 28, 2014] Version 1.7.0beta38 [October 4, 2014]
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
Removed unused "text_len" parameter from private function png_write_zTXt().
Conditionally compile some code in png_deflate_claim(), when
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
to pnglibconf.dfa.
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

View File

@@ -4891,7 +4891,14 @@ Version 1.7.0beta36 [September 27, 2014]
Version 1.7.0beta37 [September 28, 2014] Version 1.7.0beta37 [September 28, 2014]
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04. Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
Version 1.7.0beta38 [September 28, 2014] Version 1.7.0beta38 [October 4, 2014]
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
Removed unused "text_len" parameter from private function png_write_zTXt().
Conditionally compile some code in png_deflate_claim(), when
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
to pnglibconf.dfa.
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

12
png.c
View File

@@ -696,13 +696,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta38 - September 28, 2014" PNG_STRING_NEWLINE \ "libpng version 1.7.0beta38 - October 4, 2014" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.7.0beta38 - September 28, 2014\ return "libpng version 1.7.0beta38 - October 4, 2014\
Copyright (c) 1998-2014 Glenn Randers-Pehrson\ Copyright (c) 1998-2014 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -3474,8 +3474,8 @@ png_log16bit(png_uint_32 x)
* each case only the low 16 bits are relevant - the fraction - since the * each case only the low 16 bits are relevant - the fraction - since the
* integer bits (the top 4) simply determine a shift. * integer bits (the top 4) simply determine a shift.
* *
* The worst case is the 16-bit distinction between 65535 and 65534, this * The worst case is the 16-bit distinction between 65535 and 65534. This
* requires perhaps spurious accuracty in the decoding of the logarithm to * requires perhaps spurious accuracy in the decoding of the logarithm to
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
* of getting this accuracy in practice. * of getting this accuracy in practice.
* *
@@ -3563,7 +3563,7 @@ png_exp8bit(png_fixed_point lg2)
/* Get a 32-bit value: */ /* Get a 32-bit value: */
png_uint_32 x = png_exp(lg2); png_uint_32 x = png_exp(lg2);
/* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the
* second, rounding, step can't overflow because of the first, subtraction, * second, rounding, step can't overflow because of the first, subtraction,
* step. * step.
*/ */
@@ -4165,7 +4165,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
* *
* error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact
* *
* In all cases the inexact readings are off by one. * In all cases the inexact readings are only off by one.
*/ */
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED #ifdef PNG_SIMPLIFIED_READ_SUPPORTED

View File

@@ -26,6 +26,13 @@
#define PNG_READ_iTXt_MODE 7 #define PNG_READ_iTXt_MODE 7
#define PNG_ERROR_MODE 8 #define PNG_ERROR_MODE 8
#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
{ png_push_save_buffer(png_ptr); return; }
#define PNG_PUSH_SAVE_BUFFER_IF_LT_N(N) \
if (png_ptr->buffer_size < N) \
{ png_push_save_buffer(png_ptr); return; }
void PNGAPI void PNGAPI
png_process_data(png_structrp png_ptr, png_inforp info_ptr, png_process_data(png_structrp png_ptr, png_inforp info_ptr,
png_bytep buffer, png_size_t buffer_size) png_bytep buffer, png_size_t buffer_size)
@@ -46,7 +53,7 @@ png_process_data_pause(png_structrp png_ptr, int save)
{ {
if (png_ptr != NULL) if (png_ptr != NULL)
{ {
/* It's easiest for the caller if we do the save, then the caller doesn't /* It's easiest for the caller if we do the save; then the caller doesn't
* have to supply the same data again: * have to supply the same data again:
*/ */
if (save != 0) if (save != 0)
@@ -189,10 +196,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
int keep; /* unknown handling method */ int keep; /* unknown handling method */
#endif #endif
/* First we make sure we have enough data for the 4 byte chunk name /* First we make sure we have enough data for the 4-byte chunk name
* and the 4 byte chunk length before proceeding with decoding the * and the 4-byte chunk length before proceeding with decoding the
* chunk data. To fully decode each of these chunks, we also make * chunk data. To fully decode each of these chunks, we also make
* sure we have enough data in the buffer for the 4 byte CRC at the * sure we have enough data in the buffer for the 4-byte CRC at the
* end of every chunk (except IDAT, which is handled separately). * end of every chunk (except IDAT, which is handled separately).
*/ */
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
@@ -200,12 +207,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_byte chunk_length[4]; png_byte chunk_length[4];
png_byte chunk_tag[4]; png_byte chunk_tag[4];
if (png_ptr->buffer_size < 8) PNG_PUSH_SAVE_BUFFER_IF_LT_N(8)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_fill_buffer(png_ptr, chunk_length, 4); png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr); png_reset_crc(png_ptr);
@@ -249,23 +251,13 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
if (png_ptr->push_length != 13) if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length"); png_error(png_ptr, "Invalid IHDR length");
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
} }
else if (chunk_name == png_IEND) else if (chunk_name == png_IEND)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
png_ptr->process_mode = PNG_READ_DONE_MODE; png_ptr->process_mode = PNG_READ_DONE_MODE;
@@ -275,12 +267,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep); png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
if (chunk_name == png_PLTE) if (chunk_name == png_PLTE)
@@ -290,11 +277,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_PLTE) else if (chunk_name == png_PLTE)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -313,12 +296,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_gAMA_SUPPORTED #ifdef PNG_READ_gAMA_SUPPORTED
else if (png_ptr->chunk_name == png_gAMA) else if (png_ptr->chunk_name == png_gAMA)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -326,12 +304,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sBIT_SUPPORTED #ifdef PNG_READ_sBIT_SUPPORTED
else if (png_ptr->chunk_name == png_sBIT) else if (png_ptr->chunk_name == png_sBIT)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -339,12 +312,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_cHRM_SUPPORTED #ifdef PNG_READ_cHRM_SUPPORTED
else if (png_ptr->chunk_name == png_cHRM) else if (png_ptr->chunk_name == png_cHRM)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -352,12 +320,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sRGB_SUPPORTED #ifdef PNG_READ_sRGB_SUPPORTED
else if (chunk_name == png_sRGB) else if (chunk_name == png_sRGB)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -365,12 +328,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_iCCP_SUPPORTED #ifdef PNG_READ_iCCP_SUPPORTED
else if (png_ptr->chunk_name == png_iCCP) else if (png_ptr->chunk_name == png_iCCP)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -378,12 +336,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sPLT_SUPPORTED #ifdef PNG_READ_sPLT_SUPPORTED
else if (chunk_name == png_sPLT) else if (chunk_name == png_sPLT)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -391,12 +344,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tRNS_SUPPORTED #ifdef PNG_READ_tRNS_SUPPORTED
else if (chunk_name == png_tRNS) else if (chunk_name == png_tRNS)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -404,12 +352,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_bKGD_SUPPORTED #ifdef PNG_READ_bKGD_SUPPORTED
else if (chunk_name == png_bKGD) else if (chunk_name == png_bKGD)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -417,12 +360,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_hIST_SUPPORTED #ifdef PNG_READ_hIST_SUPPORTED
else if (chunk_name == png_hIST) else if (chunk_name == png_hIST)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -430,12 +368,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_pHYs_SUPPORTED #ifdef PNG_READ_pHYs_SUPPORTED
else if (chunk_name == png_pHYs) else if (chunk_name == png_pHYs)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -443,12 +376,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_oFFs_SUPPORTED #ifdef PNG_READ_oFFs_SUPPORTED
else if (chunk_name == png_oFFs) else if (chunk_name == png_oFFs)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -456,12 +384,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_pCAL_SUPPORTED #ifdef PNG_READ_pCAL_SUPPORTED
else if (chunk_name == png_pCAL) else if (chunk_name == png_pCAL)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -469,12 +392,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sCAL_SUPPORTED #ifdef PNG_READ_sCAL_SUPPORTED
else if (chunk_name == png_sCAL) else if (chunk_name == png_sCAL)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -482,12 +400,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tIME_SUPPORTED #ifdef PNG_READ_tIME_SUPPORTED
else if (chunk_name == png_tIME) else if (chunk_name == png_tIME)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -495,12 +408,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tEXt_SUPPORTED #ifdef PNG_READ_tEXt_SUPPORTED
else if (chunk_name == png_tEXt) else if (chunk_name == png_tEXt)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -508,12 +416,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_zTXt_SUPPORTED #ifdef PNG_READ_zTXt_SUPPORTED
else if (chunk_name == png_zTXt) else if (chunk_name == png_zTXt)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -521,23 +424,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_iTXt_SUPPORTED #ifdef PNG_READ_iTXt_SUPPORTED
else if (chunk_name == png_iTXt) else if (chunk_name == png_iTXt)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
else else
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) PNG_PUSH_SAVE_BUFFER_IF_FULL
{
png_push_save_buffer(png_ptr);
return;
}
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
PNG_HANDLE_CHUNK_AS_DEFAULT); PNG_HANDLE_CHUNK_AS_DEFAULT);
} }
@@ -602,12 +496,7 @@ png_push_crc_finish(png_structrp png_ptr)
} }
if (!png_ptr->skip_length) if (!png_ptr->skip_length)
{ {
if (png_ptr->buffer_size < 4) PNG_PUSH_SAVE_BUFFER_IF_LT_N(4)
{
png_push_save_buffer(png_ptr);
return;
}
png_crc_finish(png_ptr, 0); png_crc_finish(png_ptr, 0);
png_ptr->process_mode = PNG_READ_CHUNK_MODE; png_ptr->process_mode = PNG_READ_CHUNK_MODE;
} }
@@ -732,12 +621,7 @@ png_push_read_IDAT(png_structrp png_ptr)
png_byte chunk_tag[4]; png_byte chunk_tag[4];
/* TODO: this code can be commoned up with the same code in push_read */ /* TODO: this code can be commoned up with the same code in push_read */
if (png_ptr->buffer_size < 8) PNG_PUSH_SAVE_BUFFER_IF_LT_N(8)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_fill_buffer(png_ptr, chunk_length, 4); png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr); png_reset_crc(png_ptr);
@@ -812,12 +696,7 @@ png_push_read_IDAT(png_structrp png_ptr)
} }
if (!png_ptr->idat_size) if (!png_ptr->idat_size)
{ {
if (png_ptr->buffer_size < 4) PNG_PUSH_SAVE_BUFFER_IF_LT_N(4)
{
png_push_save_buffer(png_ptr);
return;
}
png_crc_finish(png_ptr, 0); png_crc_finish(png_ptr, 0);
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;

View File

@@ -998,7 +998,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
#ifdef PNG_WRITE_zTXt_SUPPORTED #ifdef PNG_WRITE_zTXt_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY); key, png_const_charp text, int compression),PNG_EMPTY);
#endif #endif
#ifdef PNG_WRITE_iTXt_SUPPORTED #ifdef PNG_WRITE_iTXt_SUPPORTED

View File

@@ -727,7 +727,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
else else
max_text = INT_MAX; max_text = INT_MAX;
/* Now allocate a new array and copy the old members in, this does all /* Now allocate a new array and copy the old members in; this does all
* the overflow checks. * the overflow checks.
*/ */
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
@@ -1061,8 +1061,8 @@ png_set_sPLT(png_structrp png_ptr,
np->depth = entries->depth; np->depth = entries->depth;
/* In the even of out-of-memory just return - there's no point keeping on /* In the event of out-of-memory just return - there's no point keeping
* trying to add sPLT chunks. * on trying to add sPLT chunks.
*/ */
length = strlen(entries->name) + 1; length = strlen(entries->name) + 1;
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length)); np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
@@ -1073,8 +1073,8 @@ png_set_sPLT(png_structrp png_ptr,
memcpy(np->name, entries->name, length); memcpy(np->name, entries->name, length);
/* IMPORTANT: we have memory now that won't get freed if something else /* IMPORTANT: we have memory now that won't get freed if something else
* goes wrong, this code must free it. png_malloc_array produces no * goes wrong; this code must free it. png_malloc_array produces no
* warnings, use a png_chunk_report (below) if there is an error. * warnings; use a png_chunk_report (below) if there is an error.
*/ */
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr, np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
entries->nentries, sizeof (png_sPLT_entry))); entries->nentries, sizeof (png_sPLT_entry)));
@@ -1113,7 +1113,7 @@ check_location(png_const_structrp png_ptr, int location)
location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT); location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
/* New in 1.6.0; copy the location and check it. This is an API /* New in 1.6.0; copy the location and check it. This is an API
* change, previously the app had to use the * change; previously the app had to use the
* png_set_unknown_chunk_location API below for each chunk. * png_set_unknown_chunk_location API below for each chunk.
*/ */
if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT)) if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))

View File

@@ -828,7 +828,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_current_row_number(png_const_structrp png_ptr) png_get_current_row_number(png_const_structrp png_ptr)
{ {
/* See the comments in png.h - this is the sub-image row when reading and /* See the comments in png.h - this is the sub-image row when reading an
* interlaced image. * interlaced image.
*/ */
if (png_ptr != NULL) if (png_ptr != NULL)

View File

@@ -310,8 +310,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
#ifdef PNG_WRITE_zTXt_SUPPORTED #ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */ /* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key, png_write_zTXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text, 0, info_ptr->text[i].text, info_ptr->text[i].compression);
info_ptr->text[i].compression);
#else #else
png_warning(png_ptr, "Unable to write compressed text"); png_warning(png_ptr, "Unable to write compressed text");
#endif #endif
@@ -404,8 +403,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_WRITE_zTXt_SUPPORTED #ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */ /* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key, png_write_zTXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text, 0, info_ptr->text[i].text, info_ptr->text[i].compression);
info_ptr->text[i].compression);
#else #else
png_warning(png_ptr, "Unable to write compressed text"); png_warning(png_ptr, "Unable to write compressed text");
#endif #endif

View File

@@ -136,7 +136,7 @@ png_write_chunk_data(png_structrp png_ptr, png_const_bytep data,
png_write_data(png_ptr, data, length); png_write_data(png_ptr, data, length);
/* Update the CRC after writing the data, /* Update the CRC after writing the data,
* in case that the user I/O routine alters it. * in case the user I/O routine alters it.
*/ */
png_calculate_crc(png_ptr, data, length); png_calculate_crc(png_ptr, data, length);
} }
@@ -181,7 +181,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
/* On 64 bit architectures 'length' may not fit in a png_uint_32. */ /* On 64 bit architectures 'length' may not fit in a png_uint_32. */
if (length > PNG_UINT_31_MAX) if (length > PNG_UINT_31_MAX)
png_error(png_ptr, "length exceeds PNG maxima"); png_error(png_ptr, "length exceeds PNG maximum");
png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
png_write_chunk_data(png_ptr, data, length); png_write_chunk_data(png_ptr, data, length);
@@ -204,7 +204,7 @@ png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
static png_alloc_size_t static png_alloc_size_t
png_image_size(png_structrp png_ptr) png_image_size(png_structrp png_ptr)
{ {
/* Only return sizes up to the maximum of a png_uint_32, do this by limiting /* Only return sizes up to the maximum of a png_uint_32; do this by limiting
* the width and height used to 15 bits. * the width and height used to 15 bits.
*/ */
png_uint_32 h = png_ptr->height; png_uint_32 h = png_ptr->height;
@@ -297,6 +297,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
{ {
if (png_ptr->zowner != 0) if (png_ptr->zowner != 0)
{ {
# if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
char msg[64]; char msg[64];
PNG_STRING_FROM_CHUNK(msg, owner); PNG_STRING_FROM_CHUNK(msg, owner);
@@ -308,6 +309,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
* are minimal. * are minimal.
*/ */
(void)png_safecat(msg, (sizeof msg), 10, " using zstream"); (void)png_safecat(msg, (sizeof msg), 10, " using zstream");
# endif
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC # if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_warning(png_ptr, msg); png_warning(png_ptr, msg);
@@ -492,7 +494,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
int ret; int ret;
/* To find the length of the output it is necessary to first compress the /* To find the length of the output it is necessary to first compress the
* input, the result is buffered rather than using the two-pass algorithm * input. The result is buffered rather than using the two-pass algorithm
* that is used on the inflate side; deflate is assumed to be slower and a * that is used on the inflate side; deflate is assumed to be slower and a
* PNG writer is assumed to have more memory available than a PNG reader. * PNG writer is assumed to have more memory available than a PNG reader.
* *
@@ -589,7 +591,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
} }
while (ret == Z_OK); while (ret == Z_OK);
/* There may be some space left in the last output buffer, this needs to /* There may be some space left in the last output buffer. This needs to
* be subtracted from output_len. * be subtracted from output_len.
*/ */
output_len -= png_ptr->zstream.avail_out; output_len -= png_ptr->zstream.avail_out;
@@ -612,7 +614,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
/* Reset zlib for another zTXt/iTXt or image data */ /* Reset zlib for another zTXt/iTXt or image data */
png_ptr->zowner = 0; png_ptr->zowner = 0;
/* The only success case is Z_STREAM_END, input_len must be 0, if not this /* The only success case is Z_STREAM_END, input_len must be 0; if not this
* is an internal error. * is an internal error.
*/ */
if (ret == Z_STREAM_END && input_len == 0) if (ret == Z_STREAM_END && input_len == 0)
@@ -728,6 +730,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
if (key_len == 0) if (key_len == 0)
return 0; return 0;
#ifdef PNG_WARNINGS_SUPPORTED
/* Try to only output one warning per keyword: */ /* Try to only output one warning per keyword: */
if (*key) /* keyword too long */ if (*key) /* keyword too long */
png_warning(png_ptr, "keyword truncated"); png_warning(png_ptr, "keyword truncated");
@@ -741,6 +744,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
} }
#endif /* PNG_WARNINGS_SUPPORTED */
return key_len; return key_len;
} }
@@ -998,7 +1002,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
* Z_FINISH: this is the end of the input, do a Z_FINISH and clean up * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
* *
* The routine manages the acquire and release of the png_ptr->zstream by * The routine manages the acquire and release of the png_ptr->zstream by
* checking and (at the end) clearing png_ptr->zowner, it does some sanity * checking and (at the end) clearing png_ptr->zowner; it does some sanity
* checks on the 'mode' flags while doing this. * checks on the 'mode' flags while doing this.
*/ */
void /* PRIVATE */ void /* PRIVATE */
@@ -1058,7 +1062,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
input_len += png_ptr->zstream.avail_in; input_len += png_ptr->zstream.avail_in;
png_ptr->zstream.avail_in = 0; png_ptr->zstream.avail_in = 0;
/* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
* that these two zstream fields are preserved across the calls, therefore * that these two zstream fields are preserved across the calls, therefore
* there is no need to set these up on entry to the loop. * there is no need to set these up on entry to the loop.
*/ */
@@ -1090,7 +1094,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
continue; continue;
} }
/* The order of these checks doesn't matter much; it just effect which /* The order of these checks doesn't matter much; it just affects which
* possible error might be detected if multiple things go wrong at once. * possible error might be detected if multiple things go wrong at once.
*/ */
if (ret == Z_OK) /* most likely return code! */ if (ret == Z_OK) /* most likely return code! */
@@ -1623,14 +1627,13 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
/* Write a compressed text chunk */ /* Write a compressed text chunk */
void /* PRIVATE */ void /* PRIVATE */
png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
png_size_t text_len, int compression) int compression)
{ {
png_uint_32 key_len; png_uint_32 key_len;
png_byte new_key[81]; png_byte new_key[81];
compression_state comp; compression_state comp;
png_debug(1, "in png_write_zTXt"); png_debug(1, "in png_write_zTXt");
PNG_UNUSED(text_len) /* Always use strlen */
if (compression == PNG_TEXT_COMPRESSION_NONE) if (compression == PNG_TEXT_COMPRESSION_NONE)
{ {

View File

@@ -740,7 +740,7 @@ chunk cHRM enables COLORSPACE
chunk gAMA enables GAMMA chunk gAMA enables GAMMA
chunk hIST chunk hIST
chunk iCCP enables COLORSPACE, GAMMA chunk iCCP enables COLORSPACE, GAMMA
chunk iTXt chunk iTXt enables TEXT
chunk oFFs chunk oFFs
chunk pCAL chunk pCAL
chunk pHYs chunk pHYs
@@ -751,7 +751,7 @@ chunk sRGB enables COLORSPACE, GAMMA, SET_OPTION
chunk tEXt requires TEXT chunk tEXt requires TEXT
chunk tIME chunk tIME
chunk tRNS chunk tRNS
chunk zTXt chunk zTXt enables TEXT
# This only affects support of the optional PLTE chunk in RGB and RGBA # This only affects support of the optional PLTE chunk in RGB and RGBA
# images. Notice that READ_ANCILLARY_CHUNKS therefore disables part # images. Notice that READ_ANCILLARY_CHUNKS therefore disables part
@@ -835,9 +835,9 @@ option SAVE_INT_32 disabled
option WRITE_OPTIMIZE_CMF requires WRITE option WRITE_OPTIMIZE_CMF requires WRITE
option READ_COMPRESSED_TEXT disabled option READ_COMPRESSED_TEXT disabled
option READ_iCCP enables READ_COMPRESSED_TEXT
option READ_iTXt enables READ_COMPRESSED_TEXT option READ_iTXt enables READ_COMPRESSED_TEXT
option READ_zTXt enables READ_COMPRESSED_TEXT option READ_zTXt enables READ_COMPRESSED_TEXT
option READ_COMPRESSED_TEXT enables READ_TEXT
option WRITE_oFFs enables SAVE_INT_32 option WRITE_oFFs enables SAVE_INT_32
option WRITE_pCAL enables SAVE_INT_32 option WRITE_pCAL enables SAVE_INT_32