mirror of
https://github.com/GNOME/libxml2.git
synced 2025-10-14 02:58:39 +08:00
tree: Guard against atype corruption
Always remove ids if `id` member is set. Untested, but this should fix CVE-2025-7425 reported against libxslt: https://gitlab.gnome.org/GNOME/libxslt/-/issues/140
This commit is contained in:
8
tree.c
8
tree.c
@@ -1691,8 +1691,8 @@ xmlFreeProp(xmlAttr *cur) {
|
||||
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
|
||||
|
||||
/* Check for ID removal -> leading to invalid references ! */
|
||||
if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) {
|
||||
xmlRemoveID(cur->doc, cur);
|
||||
if (cur->doc != NULL && cur->id != NULL) {
|
||||
xmlRemoveID(cur->doc, cur);
|
||||
}
|
||||
if (cur->children != NULL) xmlFreeNodeList(cur->children);
|
||||
DICT_FREE(cur->name)
|
||||
@@ -2503,7 +2503,7 @@ xmlNodeSetDoc(xmlNodePtr node, xmlDocPtr doc) {
|
||||
* TODO: ID attributes should also be added to the new
|
||||
* document, but it's not clear how to handle clashes.
|
||||
*/
|
||||
if (attr->atype == XML_ATTRIBUTE_ID)
|
||||
if (attr->id != NULL)
|
||||
xmlRemoveID(oldDoc, attr);
|
||||
|
||||
break;
|
||||
@@ -6569,7 +6569,7 @@ xmlSetNsProp(xmlNode *node, xmlNs *ns, const xmlChar *name,
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (prop->atype == XML_ATTRIBUTE_ID) {
|
||||
if (prop->id != NULL) {
|
||||
xmlRemoveID(node->doc, prop);
|
||||
prop->atype = XML_ATTRIBUTE_ID;
|
||||
}
|
||||
|
Reference in New Issue
Block a user