[libxslt] Detect attribute sets recursions in more cases



commit 8ad27070672b8e221eda5700bcb64fbd9c4ec0a7
Author: Daniel Veillard <veillard redhat com>
Date:   Mon Jun 29 20:02:47 2015 +0800

    Detect attribute sets recursions in more cases
    
    For https://bugzilla.gnome.org/show_bug.cgi?id=751633
    
    since we are processing those with callback with no return values
    the simplest is to get though through a recursion counter added to
    the internal routine

 doc/xsltproc.1       |  361 --------------------------------------------------
 libxslt/attributes.c |   27 +++-
 2 files changed, 23 insertions(+), 365 deletions(-)
---
diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index 2530cf5..8440b10 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -484,21 +484,27 @@ xsltGetSAS(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns) {
 }
 
 /**
- * xsltResolveSASCallback,:
+ * xsltResolveSASCallbackInt:
  * @style:  the XSLT stylesheet
  *
  * resolve the references in an attribute set.
  */
 static void
-xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+xsltResolveSASCallbackInt(xsltAttrElemPtr values, xsltStylesheetPtr style,
                       const xmlChar *name, const xmlChar *ns,
-                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+                      int depth) {
     xsltAttrElemPtr tmp;
     xsltAttrElemPtr refs;
 
     tmp = values;
     if ((name == NULL) || (name[0] == 0))
         return;
+    if (depth > 100) {
+       xsltGenericError(xsltGenericErrorContext,
+       "xsl:attribute-set : use-attribute-sets recursion detected on %s\n",
+                        name);
+       return;
+    }
     while (tmp != NULL) {
        if (tmp->set != NULL) {
            /*
@@ -523,7 +529,7 @@ xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
                    /*
                     * recurse first for cleanup
                     */
-                   xsltResolveSASCallback(refs, style, name, ns, NULL);
+                   xsltResolveSASCallbackInt(refs, style, name, ns, depth + 1);
                    /*
                     * Then merge
                     */
@@ -541,6 +547,19 @@ xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
 }
 
 /**
+ * xsltResolveSASCallback,:
+ * @style:  the XSLT stylesheet
+ *
+ * resolve the references in an attribute set.
+ */
+static void
+xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+                      const xmlChar *name, const xmlChar *ns,
+                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+    xsltResolveSASCallbackInt(values, style, name, ns, 1);
+}
+
+/**
  * xsltMergeSASCallback,:
  * @style:  the XSLT stylesheet
  *


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