From 704d03ef405b06eb462007c1dceef9ec57bb11d8 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Mon, 8 May 2017 16:47:01 +0100 Subject: [PATCH] Test extremely long namespace prefix Exercises a path in poolGrow that requires attempting to over-fill a gap of more than 1024 characters in a non-empty pool. --- expat/tests/runtests.c | 84 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index ef4eb473..70691a1c 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -5635,6 +5635,89 @@ START_TEST(test_ns_reserved_attributes_2) } END_TEST +/* Test string pool handling of namespace names of 2048 characters */ +/* Exercises a particular string pool growth path */ +START_TEST(test_ns_extremely_long_prefix) +{ + const char *text = + "" + ""; + + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), + XML_FALSE) == XML_STATUS_ERROR) + xml_failure(parser); +} +END_TEST + + /* Control variable; the number of times duff_allocator() will successfully allocate */ #define ALLOC_ALWAYS_SUCCEED (-1) #define REALLOC_ALWAYS_SUCCEED (-1) @@ -10226,6 +10309,7 @@ make_suite(void) tcase_add_test(tc_namespace, test_ns_extend_uri_buffer); tcase_add_test(tc_namespace, test_ns_reserved_attributes); tcase_add_test(tc_namespace, test_ns_reserved_attributes_2); + tcase_add_test(tc_namespace, test_ns_extremely_long_prefix); suite_add_tcase(s, tc_misc); tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);