tests: Cover CVE-2022-25236
This commit is contained in:
parent
a2fe525e66
commit
2de077423f
@ -7220,6 +7220,35 @@ START_TEST(test_ns_double_colon_doctype) {
|
|||||||
}
|
}
|
||||||
END_TEST
|
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
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
|
/* Control variable; the number of times duff_allocator() will successfully
|
||||||
* allocate */
|
* allocate */
|
||||||
#define ALLOC_ALWAYS_SUCCEED (-1)
|
#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_utf16_doctype);
|
||||||
tcase_add_test(tc_namespace, test_ns_invalid_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_double_colon_doctype);
|
||||||
|
tcase_add_test(tc_namespace, test_ns_separator_in_uri);
|
||||||
|
|
||||||
suite_add_tcase(s, tc_misc);
|
suite_add_tcase(s, tc_misc);
|
||||||
tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);
|
tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);
|
||||||
|
Loading…
Reference in New Issue
Block a user