提交 db67cba8 编写于 作者: G Glenn Randers-Pehrson

[libpng16] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).

Ignore "#" delimited comments in input file to pnm2png.c.
上级 2aa6c96e
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
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
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
(subscription required; visit
......
......@@ -4528,7 +4528,14 @@ Version 1.6.3beta04 [May 6, 2013]
Calculate our own zlib windowBits when decoding rather than trusting the
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
(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)
{
int i = 0;
int ret;
/* remove white-space */
/* remove white-space and comment lines */
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] == ' '));
/* read string */
do
{
ret = fgetc(pnm_file);
if (ret == EOF) break;
i++;
token[i] = (unsigned char) fgetc (pnm_file);
token[i] = (unsigned char) ret;
}
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
......
......@@ -4163,7 +4163,8 @@ png_read_finish_row(png_structrp png_ptr)
}
#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
* possible sliding window needed to contain the entire uncompressed image.
*/
......@@ -4230,6 +4231,7 @@ png_read_image_size(png_structrp png_ptr)
return 0xffffffffU;
}
#endif /* ZLIB_VERNUM */
#endif /* PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED */
void /* PRIVATE */
......@@ -4516,23 +4518,37 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
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
if (png_inflate_claim(png_ptr, png_IDAT,
required_window_bits(png_read_image_size(png_ptr))) != Z_OK)
/* To do in libpng17: get windowBits from the CMF bytes and select the
* 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
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
png_error(png_ptr, png_ptr->zstream.msg);
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_ptr->flags |= PNG_FLAG_ROW_INIT;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册