Test substituted public entity with long name against failing realloc
This commit is contained in:
parent
3c526f6d6c
commit
1adb2438d0
@ -5887,29 +5887,7 @@ external_entity_public(XML_Parser parser,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
const char *text1 =
|
||||
"<!ELEMENT doc EMPTY>\n"
|
||||
"<!ENTITY % e1 PUBLIC 'foo' 'bar.ent'>\n"
|
||||
"<!ENTITY % "
|
||||
/* Each line is 64 characters */
|
||||
"ThisIsAStupidlyLongParameterNameIntendedToTriggerPoolGrowth12345"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
" '%e1;'>\n"
|
||||
"%e1;\n";
|
||||
const char *text1 = (const char *)XML_GetUserData(parser);
|
||||
const char *text2 = "<!ATTLIST doc a CDATA 'value'>";
|
||||
const char *text;
|
||||
XML_Parser ext_parser;
|
||||
@ -5935,6 +5913,29 @@ START_TEST(test_alloc_public_entity_value)
|
||||
const char *text =
|
||||
"<!DOCTYPE doc SYSTEM 'http://example.org/'>\n"
|
||||
"<doc></doc>\n";
|
||||
char dtd_text[] =
|
||||
"<!ELEMENT doc EMPTY>\n"
|
||||
"<!ENTITY % e1 PUBLIC 'foo' 'bar.ent'>\n"
|
||||
"<!ENTITY % "
|
||||
/* Each line is 64 characters */
|
||||
"ThisIsAStupidlyLongParameterNameIntendedToTriggerPoolGrowth12345"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
" '%e1;'>\n"
|
||||
"%e1;\n";
|
||||
int i;
|
||||
#define MAX_ALLOC_COUNT 25
|
||||
int repeat = 0;
|
||||
@ -5952,6 +5953,7 @@ START_TEST(test_alloc_public_entity_value)
|
||||
}
|
||||
allocation_count = i;
|
||||
dummy_handler_flags = 0;
|
||||
XML_SetUserData(parser, dtd_text);
|
||||
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||
XML_SetExternalEntityRefHandler(parser, external_entity_public);
|
||||
/* Provoke a particular code path */
|
||||
@ -5971,6 +5973,69 @@ START_TEST(test_alloc_public_entity_value)
|
||||
#undef MAX_ALLOC_COUNT
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_alloc_realloc_subst_public_entity_value)
|
||||
{
|
||||
const char *text =
|
||||
"<!DOCTYPE doc SYSTEM 'http://example.org/'>\n"
|
||||
"<doc></doc>\n";
|
||||
char dtd_text[] =
|
||||
"<!ELEMENT doc EMPTY>\n"
|
||||
"<!ENTITY % "
|
||||
/* Each line is 64 characters */
|
||||
"ThisIsAStupidlyLongParameterNameIntendedToTriggerPoolGrowth12345"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
" PUBLIC 'foo' 'bar.ent'>\n"
|
||||
"%ThisIsAStupidlyLongParameterNameIntendedToTriggerPoolGrowth12345"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"
|
||||
"ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP;";
|
||||
int i;
|
||||
#define MAX_REALLOC_COUNT 10
|
||||
|
||||
for (i = 0; i < MAX_REALLOC_COUNT; i++) {
|
||||
reallocation_count = i;
|
||||
XML_SetUserData(parser, dtd_text);
|
||||
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||
XML_SetExternalEntityRefHandler(parser, external_entity_public);
|
||||
if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
|
||||
XML_TRUE) != XML_STATUS_ERROR)
|
||||
break;
|
||||
XML_ParserReset(parser, NULL);
|
||||
}
|
||||
if (i == 0)
|
||||
fail("Parsing worked despite failing reallocation");
|
||||
if (i == MAX_REALLOC_COUNT)
|
||||
fail("Parsing failed at max reallocation count");
|
||||
}
|
||||
#undef MAX_REALLOC_COUNT
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_alloc_parse_public_doctype)
|
||||
{
|
||||
const char *text =
|
||||
@ -7342,6 +7407,7 @@ make_suite(void)
|
||||
tcase_add_test(tc_alloc, test_alloc_ext_entity_realloc_buffer);
|
||||
tcase_add_test(tc_alloc, test_alloc_realloc_many_attributes);
|
||||
tcase_add_test(tc_alloc, test_alloc_public_entity_value);
|
||||
tcase_add_test(tc_alloc, test_alloc_realloc_subst_public_entity_value);
|
||||
tcase_add_test(tc_alloc, test_alloc_parse_public_doctype);
|
||||
tcase_add_test(tc_alloc, test_alloc_parse_public_doctype_long_name);
|
||||
tcase_add_test(tc_alloc, test_alloc_set_foreign_dtd);
|
||||
|
Loading…
Reference in New Issue
Block a user