From 7f576964d8a0cfadd5a76d866f7c9010f8e7888a Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 18 Jan 2016 19:19:14 -0800 Subject: [PATCH] pngunknown.c: handle unknown IDAT This is the test backported from 1.7 to ensure that when treating IDATs as unknown the test does not fail if there are more than one IDAT chunks in the file. Signed-off-by: John Bowler --- contrib/libtests/pngunknown.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c index 8bbc5d4ad..89077e4b1 100644 --- a/contrib/libtests/pngunknown.c +++ b/contrib/libtests/pngunknown.c @@ -1002,6 +1002,20 @@ perform_one_test(FILE *fp, int argc, const char **argv, def = check(fp, argc, argv, flags[1], d, set_callback); + /* If IDAT is being handled as unknown the image read is skipped and all the + * IDATs after the first end up in the end info struct, so in this case add + * IDAT to the list of unknowns. (Do this after 'check' above sets the + * chunk_info 'keep' fields.) + * + * Note that the flag setting has to be in the 'known' field to avoid + * triggeriing the consistency check below and the flag must only be set if + * there are multiple IDATs, so if the check above did find an unknown IDAT + * after IDAT. + */ + if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT && + (flags[1][3] & PNG_INFO_IDAT) != 0) + flags[0][2] |= PNG_INFO_IDAT; + /* Chunks should either be known or unknown, never both and this should apply * whether the chunk is before or after the IDAT (actually, the app can * probably change this by swapping the handling after the image, but this