mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
[CVE-2025-24928] Fix stack-buffer-overflow in xmlSnprintfElements
Fixes #847.
This commit is contained in:
parent
245b70d7d2
commit
858ca26c06
25
valid.c
25
valid.c
@ -5057,25 +5057,26 @@ xmlSnprintfElements(char *buf, int size, xmlNodePtr node, int glob) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE: {
|
||||||
|
int qnameLen = xmlStrlen(cur->name);
|
||||||
|
|
||||||
|
if ((cur->ns != NULL) && (cur->ns->prefix != NULL))
|
||||||
|
qnameLen += xmlStrlen(cur->ns->prefix) + 1;
|
||||||
|
if (size - len < qnameLen + 10) {
|
||||||
|
if ((size - len > 4) && (buf[len - 1] != '.'))
|
||||||
|
strcat(buf, " ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
|
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
|
||||||
if (size - len < xmlStrlen(cur->ns->prefix) + 10) {
|
|
||||||
if ((size - len > 4) && (buf[len - 1] != '.'))
|
|
||||||
strcat(buf, " ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
strcat(buf, (char *) cur->ns->prefix);
|
strcat(buf, (char *) cur->ns->prefix);
|
||||||
strcat(buf, ":");
|
strcat(buf, ":");
|
||||||
}
|
}
|
||||||
if (size - len < xmlStrlen(cur->name) + 10) {
|
if (cur->name != NULL)
|
||||||
if ((size - len > 4) && (buf[len - 1] != '.'))
|
strcat(buf, (char *) cur->name);
|
||||||
strcat(buf, " ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
strcat(buf, (char *) cur->name);
|
|
||||||
if (cur->next != NULL)
|
if (cur->next != NULL)
|
||||||
strcat(buf, " ");
|
strcat(buf, " ");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
if (xmlIsBlankNode(cur))
|
if (xmlIsBlankNode(cur))
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user