mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
fix(XML): fuzzing stack overflow (#4629). Limit maximum XML element depth.
This commit is contained in:
@@ -104,6 +104,23 @@ void ParserWriterTest::testParseWriteSimple()
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::testMaxElementDepth()
|
||||
{
|
||||
DOMParser parser;
|
||||
parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
|
||||
parser.setMaxElementDepth(2);
|
||||
try
|
||||
{
|
||||
AutoPtr<Document> pDoc = parser.parseString(XHTML);
|
||||
fail("max element depth exceeded - must throw");
|
||||
}
|
||||
catch (const Poco::Exception&)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParserWriterTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -121,6 +138,7 @@ CppUnit::Test* ParserWriterTest::suite()
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteXHTML2);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testParseWriteSimple);
|
||||
CppUnit_addTest(pSuite, ParserWriterTest, testMaxElementDepth);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ public:
|
||||
|
||||
void testParseWriteXHTML();
|
||||
void testParseWriteXHTML2();
|
||||
void testParseWriteWSDL();
|
||||
void testParseWriteSimple();
|
||||
void testMaxElementDepth();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
Reference in New Issue
Block a user