mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-27 13:33:17 +08:00
Fix buffer overrun when parsing comments inside DOCTYPE
This commit is contained in:
parent
604861e520
commit
0542b1869b
@ -2352,7 +2352,7 @@ PUGI__NS_BEGIN
|
|||||||
PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && s[2] == '>'); // no need for ENDSWITH because --> can't terminate proper doctype
|
PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && s[2] == '>'); // no need for ENDSWITH because --> can't terminate proper doctype
|
||||||
if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s);
|
if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s);
|
||||||
|
|
||||||
s += 4;
|
s += 3;
|
||||||
}
|
}
|
||||||
else PUGI__THROW_ERROR(status_bad_doctype, s);
|
else PUGI__THROW_ERROR(status_bad_doctype, s);
|
||||||
|
|
||||||
|
@ -1091,3 +1091,17 @@ TEST(parse_close_tag_eof)
|
|||||||
CHECK(doc.load_buffer_inplace(test2, 12 * sizeof(char_t)).status == status_end_element_mismatch);
|
CHECK(doc.load_buffer_inplace(test2, 12 * sizeof(char_t)).status == status_end_element_mismatch);
|
||||||
CHECK_STRING(doc.first_child().name(), STR("node"));
|
CHECK_STRING(doc.first_child().name(), STR("node"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(parse_fuzz_doctype)
|
||||||
|
{
|
||||||
|
unsigned char data[] =
|
||||||
|
{
|
||||||
|
0x3b, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0xef, 0xbb, 0xbf, 0x3c, 0x3f, 0x78,
|
||||||
|
0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22,
|
||||||
|
0x3f, 0x3e, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0xe9, 0x80, 0xb1, 0xe5, 0xa0, 0xb1, 0xe3, 0x82, 0xb4,
|
||||||
|
0xe3, 0x83, 0xb3, 0x20, 0xef, 0x83, 0x97, 0xe3, 0xa9, 0x2a, 0x20, 0x2d, 0x2d, 0x3e
|
||||||
|
};
|
||||||
|
|
||||||
|
xml_document doc;
|
||||||
|
CHECK(doc.load_buffer(data, sizeof(data)).status == status_bad_doctype);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user