summaryrefslogtreecommitdiff
path: root/expat
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2022-02-12 00:51:43 +0100
committerSebastian Pipping <sebastian@pipping.org>2022-02-16 02:07:31 +0100
commit2de077423fb22750ebea599677d523b53cb93b1d (patch)
tree475e286468a116b02c80bb6532184dc2f89b6a0b /expat
parenta2fe525e660badd64b6c557c2b1ec26ddc07f6e4 (diff)
downloadlibexpat-git-2de077423fb22750ebea599677d523b53cb93b1d.tar.gz
tests: Cover CVE-2022-25236
Diffstat (limited to 'expat')
-rw-r--r--expat/tests/runtests.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c
index d07203f2..bc5344b1 100644
--- a/expat/tests/runtests.c
+++ b/expat/tests/runtests.c
@@ -7220,6 +7220,35 @@ START_TEST(test_ns_double_colon_doctype) {
}
END_TEST
+START_TEST(test_ns_separator_in_uri) {
+ struct test_case {
+ enum XML_Status expectedStatus;
+ const char *doc;
+ };
+ struct test_case cases[] = {
+ {XML_STATUS_OK, "<doc xmlns='one_two' />"},
+ {XML_STATUS_ERROR, "<doc xmlns='one&#x0A;two' />"},
+ };
+
+ size_t i = 0;
+ size_t failCount = 0;
+ for (; i < sizeof(cases) / sizeof(cases[0]); i++) {
+ XML_Parser parser = XML_ParserCreateNS(NULL, '\n');
+ XML_SetElementHandler(parser, dummy_start_element, dummy_end_element);
+ if (XML_Parse(parser, cases[i].doc, (int)strlen(cases[i].doc),
+ /*isFinal*/ XML_TRUE)
+ != cases[i].expectedStatus) {
+ failCount++;
+ }
+ XML_ParserFree(parser);
+ }
+
+ if (failCount) {
+ fail("Namespace separator handling is broken");
+ }
+}
+END_TEST
+
/* Control variable; the number of times duff_allocator() will successfully
* allocate */
#define ALLOC_ALWAYS_SUCCEED (-1)
@@ -11905,6 +11934,7 @@ make_suite(void) {
tcase_add_test(tc_namespace, test_ns_utf16_doctype);
tcase_add_test(tc_namespace, test_ns_invalid_doctype);
tcase_add_test(tc_namespace, test_ns_double_colon_doctype);
+ tcase_add_test(tc_namespace, test_ns_separator_in_uri);
suite_add_tcase(s, tc_misc);
tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);