aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-08-04 00:58:46 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-08-04 00:58:46 +0000
commit5ee43b06000bf42aea1955260aa867c6e466e0a4 (patch)
tree2758f01e3af0ddcfd83b299598397a3414fda8ce
parent7b68df974b4c788d7a43d66950af431ad3898c70 (diff)
downloadandroid_external_libxml2-5ee43b06000bf42aea1955260aa867c6e466e0a4.tar.gz
android_external_libxml2-5ee43b06000bf42aea1955260aa867c6e466e0a4.tar.bz2
android_external_libxml2-5ee43b06000bf42aea1955260aa867c6e466e0a4.zip
trying to fix #118754 of possible recursion in the catalogs. Not
* catalog.c: trying to fix #118754 of possible recursion in the catalogs. Not fantastically happy about the current fix since it's likely to break under very thread intensive concurrent access to the catalog. Better solution might to keep the depth an extra argument to the resolution functions. Daniel
-rw-r--r--ChangeLog8
-rw-r--r--catalog.c35
2 files changed, 40 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f064b03..a5f487ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+ * catalog.c: trying to fix #118754 of possible recursion in the
+ catalogs. Not fantastically happy about the current fix since
+ it's likely to break under very thread intensive concurrent
+ access to the catalog. Better solution might to keep the depth
+ an extra argument to the resolution functions.
+
Sun Aug 3 18:56:54 EDT 2003 Daniel Veillard <daniel@veillard.com>
* valid.c: fixed bug #118712 about mixed content, and namespaced
diff --git a/catalog.c b/catalog.c
index 06bffc66..d307bf4e 100644
--- a/catalog.c
+++ b/catalog.c
@@ -42,6 +42,7 @@
#include <libxml/globals.h>
#define MAX_DELEGATE 50
+#define MAX_CATAL_DEPTH 50
/**
* TODO:
@@ -115,6 +116,7 @@ struct _xmlCatalogEntry {
xmlChar *URL; /* The expanded URL using the base */
xmlCatalogPrefer prefer;
int dealloc;
+ int depth;
};
typedef enum {
@@ -230,6 +232,7 @@ xmlNewCatalogEntry(xmlCatalogEntryType type, const xmlChar *name,
ret->URL = NULL;
ret->prefer = prefer;
ret->dealloc = 0;
+ ret->depth = 0;
return(ret);
}
@@ -1443,6 +1446,20 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
int haveNext = 0;
/*
+ * protection against loops
+ */
+ if (catal->depth > MAX_CATAL_DEPTH) {
+ if (catal->name != NULL)
+ xmlGenericError(xmlGenericErrorContext,
+ "Detected recursion in catalog %s\n", catal->name);
+ else
+ xmlGenericError(xmlGenericErrorContext,
+ "Detected recursion in catalog\n");
+ return(NULL);
+ }
+ catal->depth++;
+
+ /*
* First tries steps 2/ 3/ 4/ if a system ID is provided.
*/
if (sysID != NULL) {
@@ -1457,6 +1474,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
if (xmlDebugCatalogs)
xmlGenericError(xmlGenericErrorContext,
"Found system match %s\n", cur->name);
+ catal->depth--;
return(xmlStrdup(cur->URL));
}
break;
@@ -1487,6 +1505,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
ret = xmlStrdup(rewrite->URL);
if (ret != NULL)
ret = xmlStrcat(ret, &sysID[lenrewrite]);
+ catal->depth--;
return(ret);
}
if (haveDelegate) {
@@ -1520,8 +1539,10 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
"Trying system delegate %s\n", cur->URL);
ret = xmlCatalogListXMLResolve(
cur->children, NULL, sysID);
- if (ret != NULL)
+ if (ret != NULL) {
+ catal->depth--;
return(ret);
+ }
}
}
cur = cur->next;
@@ -1529,6 +1550,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
/*
* Apply the cut algorithm explained in 4/
*/
+ catal->depth--;
return(XML_CATAL_BREAK);
}
}
@@ -1545,6 +1567,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
if (xmlDebugCatalogs)
xmlGenericError(xmlGenericErrorContext,
"Found public match %s\n", cur->name);
+ catal->depth--;
return(xmlStrdup(cur->URL));
}
break;
@@ -1595,8 +1618,10 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
"Trying public delegate %s\n", cur->URL);
ret = xmlCatalogListXMLResolve(
cur->children, pubID, NULL);
- if (ret != NULL)
+ if (ret != NULL) {
+ catal->depth--;
return(ret);
+ }
}
}
cur = cur->next;
@@ -1604,6 +1629,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
/*
* Apply the cut algorithm explained in 4/
*/
+ catal->depth--;
return(XML_CATAL_BREAK);
}
}
@@ -1616,14 +1642,17 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
}
if (cur->children != NULL) {
ret = xmlCatalogListXMLResolve(cur->children, pubID, sysID);
- if (ret != NULL)
+ if (ret != NULL) {
+ catal->depth--;
return(ret);
+ }
}
}
cur = cur->next;
}
}
+ catal->depth--;
return(NULL);
}