[libxml2] Limit recursion depth in xmlXPathCompOpEvalPredicate



commit 14ed63b7d09fce1a78f925e0a1d668c12e011fec
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Wed May 8 12:00:51 2019 +0200

    Limit recursion depth in xmlXPathCompOpEvalPredicate

 xpath.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/xpath.c b/xpath.c
index 30e9959a..031772ce 100644
--- a/xpath.c
+++ b/xpath.c
@@ -11833,8 +11833,12 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
                 "xmlXPathCompOpEvalPredicate: Expected a predicate\n");
             XP_ERROR(XPATH_INVALID_OPERAND);
        }
+        if (ctxt->context->depth >= ctxt->context->maxDepth)
+            XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED);
+        ctxt->context->depth += 1;
        xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set,
                                     1, set->nodeNr, hasNsNodes);
+        ctxt->context->depth -= 1;
        CHECK_ERROR;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]