mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
Ignore "#" delimited comments in input file to pnm2png.c.
This commit is contained in:
parent
2aa6c96e5d
commit
db67cba8d4
11
ANNOUNCE
11
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.6.3beta05 - May 6, 2013
|
Libpng 1.6.3beta05 - May 7, 2013
|
||||||
|
|
||||||
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.
|
||||||
@ -45,7 +45,14 @@ Version 1.6.3beta04 [May 6, 2013]
|
|||||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||||
CMF bytes in the PNG datastream.
|
CMF bytes in the PNG datastream.
|
||||||
|
|
||||||
Version 1.6.3beta05 [May 6, 2013]
|
Version 1.6.3beta05 [May 7, 2013]
|
||||||
|
Choose to use windowBits==15 or the zlib header setting via the
|
||||||
|
benign-errors setting. If benign errors are allowed, then ignore
|
||||||
|
the windowBits setting in the zlib header.
|
||||||
|
Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
|
||||||
|
undid the improvement in beta04.
|
||||||
|
Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
|
||||||
|
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||||
|
|
||||||
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
|
||||||
|
9
CHANGES
9
CHANGES
@ -4528,7 +4528,14 @@ Version 1.6.3beta04 [May 6, 2013]
|
|||||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||||
CMF bytes in the PNG datastream.
|
CMF bytes in the PNG datastream.
|
||||||
|
|
||||||
Version 1.6.3beta05 [May 6, 2013]
|
Version 1.6.3beta05 [May 7, 2013]
|
||||||
|
Choose to use windowBits==15 or the zlib header setting via the
|
||||||
|
benign-errors setting. If benign errors are allowed, then ignore
|
||||||
|
the windowBits setting in the zlib header.
|
||||||
|
Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
|
||||||
|
undid the improvement in beta04.
|
||||||
|
Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
|
||||||
|
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||||
|
|
||||||
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
|
||||||
|
@ -460,19 +460,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
void get_token(FILE *pnm_file, char *token)
|
void get_token(FILE *pnm_file, char *token)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* remove white-space */
|
/* remove white-space and comment lines */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
token[i] = (unsigned char) fgetc (pnm_file);
|
ret = fgetc(pnm_file);
|
||||||
|
if (ret == '#') {
|
||||||
|
/* the rest of this line is a comment */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ret = fgetc(pnm_file);
|
||||||
|
}
|
||||||
|
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||||
|
}
|
||||||
|
if (ret == EOF) break;
|
||||||
|
token[i] = (unsigned char) ret;
|
||||||
}
|
}
|
||||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||||
|
|
||||||
/* read string */
|
/* read string */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
ret = fgetc(pnm_file);
|
||||||
|
if (ret == EOF) break;
|
||||||
i++;
|
i++;
|
||||||
token[i] = (unsigned char) fgetc (pnm_file);
|
token[i] = (unsigned char) ret;
|
||||||
}
|
}
|
||||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||||
|
|
||||||
|
42
pngrutil.c
42
pngrutil.c
@ -4164,6 +4164,7 @@ png_read_finish_row(png_structrp png_ptr)
|
|||||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
|
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
|
||||||
|
#if ZLIB_VERNUM > 0x1280
|
||||||
/* This is the code to to select a windowBits value to match the smallest
|
/* This is the code to to select a windowBits value to match the smallest
|
||||||
* possible sliding window needed to contain the entire uncompressed image.
|
* possible sliding window needed to contain the entire uncompressed image.
|
||||||
*/
|
*/
|
||||||
@ -4230,6 +4231,7 @@ png_read_image_size(png_structrp png_ptr)
|
|||||||
return 0xffffffffU;
|
return 0xffffffffU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* ZLIB_VERNUM */
|
||||||
#endif /* PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED */
|
#endif /* PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED */
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
@ -4516,23 +4518,37 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||||||
png_free(png_ptr, buffer);
|
png_free(png_ptr, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally claim the zstream for the inflate of the IDAT data, using the
|
|
||||||
* windowBts predicted from the uncompressed data size, not the value from
|
|
||||||
* the stream. If READ_OPTIMIZE_WINDOWBITS_SUPPORTED is not defined, then
|
|
||||||
* simply use a 32kbyte window (windowBits=15).
|
|
||||||
*
|
|
||||||
* To do: make this behavior optional via a run-time png_set_something(),
|
|
||||||
* with options to use windowBits=0 (use the zlib header data),
|
|
||||||
* windowBits=15 (use a 32kbyte window), or required_window_bits
|
|
||||||
* computed from the image size, pixel size, and interlacing setting.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
|
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
|
||||||
if (png_inflate_claim(png_ptr, png_IDAT,
|
/* To do in libpng17: get windowBits from the CMF bytes and select the
|
||||||
required_window_bits(png_read_image_size(png_ptr))) != Z_OK)
|
* smaller of that and the required_window_bits. Requires a one-byte
|
||||||
|
* lookahead into the first IDAT chunk data, and requires actually
|
||||||
|
* injecting the revised CMF bytes into the datastream before reading.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
#if ZLIB_VERNUM < 0x1290
|
||||||
|
unsigned int windowBits;
|
||||||
|
#endif /* ZLIB_VERNUM */
|
||||||
|
|
||||||
|
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||||
|
{
|
||||||
|
#if ZLIB_VERNUM < 0x1290
|
||||||
|
windowBits=15;
|
||||||
#else
|
#else
|
||||||
if (png_inflate_claim(png_ptr, png_IDAT, 15) != Z_OK)
|
/* Compute required windowBits from the image size, pixel size, and
|
||||||
|
* interlacing setting.
|
||||||
|
*/
|
||||||
|
windowBits=required_window_bits(png_read_image_size(png_ptr));
|
||||||
|
#endif /* ZLIB_VERNUM */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
windowBits=0; /* Use the setting from the zlib CMF bytes */
|
||||||
|
|
||||||
|
/* Finally claim the zstream for the inflate of the IDAT data */
|
||||||
|
if (png_inflate_claim(png_ptr, png_IDAT, windowBits) != Z_OK)
|
||||||
png_error(png_ptr, png_ptr->zstream.msg);
|
png_error(png_ptr, png_ptr->zstream.msg);
|
||||||
|
}
|
||||||
|
|
||||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user