mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
Bug 763071: heap-buffer-overflow in xmlStrncat <https://bugzilla.gnome.org/show_bug.cgi?id=763071>
* xmlstring.c: (xmlStrncat): Return NULL if xmlStrlen returns a negative length. (xmlStrncatNew): Ditto.
This commit is contained in:
parent
8f30bdff69
commit
8fbbf5513d
@ -457,6 +457,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
||||
return(xmlStrndup(add, len));
|
||||
|
||||
size = xmlStrlen(cur);
|
||||
if (size < 0)
|
||||
return(NULL);
|
||||
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(NULL, NULL);
|
||||
@ -484,14 +486,19 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
|
||||
int size;
|
||||
xmlChar *ret;
|
||||
|
||||
if (len < 0)
|
||||
if (len < 0) {
|
||||
len = xmlStrlen(str2);
|
||||
if (len < 0)
|
||||
return(NULL);
|
||||
}
|
||||
if ((str2 == NULL) || (len == 0))
|
||||
return(xmlStrdup(str1));
|
||||
if (str1 == NULL)
|
||||
return(xmlStrndup(str2, len));
|
||||
|
||||
size = xmlStrlen(str1);
|
||||
if (size < 0)
|
||||
return(NULL);
|
||||
ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlErrMemory(NULL, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user