From 31cb5b01fab86b0cf68f9f2f3b13a2cc45cee0d1 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 13 Nov 2024 13:54:37 +0100 Subject: [PATCH] tests: Protect against accidental misuse of single-bytes approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Please see commit 60dffa148c3ce26799cb933afdb0dc3581ad2098 ("tests: Use normal XML_Parse in test_suspend_resume_internal_entity") for more details on the related issue. In reaction to analysis by Berkay Eren Ürün. --- expat/tests/common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/expat/tests/common.c b/expat/tests/common.c index 3aea8d74..af516f96 100644 --- a/expat/tests/common.c +++ b/expat/tests/common.c @@ -202,6 +202,12 @@ _XML_Parse_SINGLE_BYTES(XML_Parser parser, const char *s, int len, for (; len > chunksize; len -= chunksize, s += chunksize) { enum XML_Status res = XML_Parse(parser, s, chunksize, XML_FALSE); if (res != XML_STATUS_OK) { + if ((res == XML_STATUS_SUSPENDED) && (len > chunksize)) { + fail("Use of function _XML_Parse_SINGLE_BYTES with a chunk size " + "greater than 0 (from g_chunkSize) does not work well with " + "suspension. Please consider use of plain XML_Parse at this " + "place in your test, instead."); + } return res; } }