[libpng17] Added libpng 1.5 checks to pngvalid.c

This commit is contained in:
John Bowler
2013-12-27 07:53:50 -06:00
committed by Glenn Randers-Pehrson
parent 8df7c46e5b
commit ad1a4c8cc3
3 changed files with 17 additions and 8 deletions

View File

@@ -4867,7 +4867,7 @@ standard_check_text(png_const_structp pp, png_const_textp tp,
static void
standard_text_validate(standard_display *dp, png_const_structp pp,
png_infop pi)
png_infop pi, int check_end)
{
png_textp tp = NULL;
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
@@ -4875,7 +4875,13 @@ standard_text_validate(standard_display *dp, png_const_structp pp,
if (num_text == 2 && tp != NULL)
{
standard_check_text(pp, tp, "image name", dp->ps->current->name);
standard_check_text(pp, tp+1, "end marker", "end");
/* This exists because prior to 1.6 the progressive reader left the
* png_struct z_stream unreset at the end of the image, so subsequent
* attempts to use it simply returns Z_STREAM_END.
*/
if (check_end)
standard_check_text(pp, tp+1, "end marker", "end");
}
else
@@ -4888,7 +4894,7 @@ standard_text_validate(standard_display *dp, png_const_structp pp,
}
}
#else
# define standard_text_validate(dp,pp,pi) ((void)0)
# define standard_text_validate(dp,pp,pi,check_end) ((void)0)
#endif
static void
@@ -4978,7 +4984,8 @@ standard_end(png_structp ppIn, png_infop pi)
/* Validate the image - progressive reading only produces one variant for
* interlaced images.
*/
standard_text_validate(dp, pp, pi);
standard_text_validate(dp, pp, pi,
PNG_LIBPNG_VER >= 10600/*check_end: see comments above*/);
standard_image_validate(dp, pp, 0, -1);
}
@@ -5049,7 +5056,7 @@ standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id,
*/
if (!d.speed)
{
standard_text_validate(&d, pp, pi);
standard_text_validate(&d, pp, pi, 1/*check_end*/);
standard_image_validate(&d, pp, 0, 1);
}
else