Commit 77c26bad authored by Nick Wellnhofer's avatar Nick Wellnhofer
Browse files

Don't set maxDepth in XPath contexts

The maximum recursion depth is hardcoded in libxml2 now.
parent 82465776
......@@ -182,7 +182,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
xptrctxt->opLimit = ctxt->context->opLimit;
xptrctxt->opCount = ctxt->context->opCount;
xptrctxt->maxDepth = ctxt->context->maxDepth - ctxt->context->depth;
xptrctxt->depth = ctxt->context->depth;
resObj = xmlXPtrEval(fragment, xptrctxt);
......
......@@ -183,7 +183,6 @@ xsltFuzzXPathInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
xpctxt = tctxt->xpathCtxt;
/* Resource limits to avoid timeouts and call stack overflows */
xpctxt->maxDepth = 500;
xpctxt->opLimit = 500000;
/* Test namespaces used in xpath.xml */
......@@ -314,12 +313,6 @@ xsltFuzzXsltInit(int *argc_p ATTRIBUTE_UNUSED, char ***argv_p,
return 0;
}
static void
xsltSetXPathResourceLimits(xmlXPathContextPtr ctxt) {
ctxt->maxDepth = 200;
ctxt->opLimit = 100000;
}
xmlChar *
xsltFuzzXslt(const char *data, size_t size) {
xmlDocPtr xsltDoc;
......@@ -349,7 +342,7 @@ xsltFuzzXslt(const char *data, size_t size) {
xmlFreeDoc(xsltDoc);
return NULL;
}
xsltSetXPathResourceLimits(sheet->xpathCtxt);
sheet->xpathCtxt->opLimit = 100000;
sheet->xpathCtxt->opCount = 0;
if (xsltParseStylesheetUser(sheet, xsltDoc) != 0) {
xsltFreeStylesheet(sheet);
......@@ -361,7 +354,7 @@ xsltFuzzXslt(const char *data, size_t size) {
xsltSetCtxtSecurityPrefs(sec, ctxt);
ctxt->maxTemplateDepth = 100;
ctxt->opLimit = 20000;
xsltSetXPathResourceLimits(ctxt->xpathCtxt);
ctxt->xpathCtxt->opLimit = 100000;
ctxt->xpathCtxt->opCount = sheet->xpathCtxt->opCount;
result = xsltApplyStylesheetUser(sheet, doc, NULL, NULL, NULL, ctxt);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment