1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-23 01:52:48 +03:00

Fixed a segfault during text concatenation when validating a node tree:

* xmlschemas.c xmlstring.c: Fixed a segfault during
  text concatenation when validating a node tree:
  xmlStrncat was called with a @len of -1; but unlike
  xmlStrncatNew, it does not calculate the length
  automatically in such a case (reported by Judy Hay
  on the mailing list).
  Updated the descriptions of the involved string
  functions to note this.
This commit is contained in:
Kasimier T. Buchcik
2005-12-20 10:48:33 +00:00
parent 9a2724d847
commit 5bb0c08d2f
3 changed files with 21 additions and 4 deletions

View File

@@ -1,3 +1,14 @@
Tue Dec 20 11:43:06 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.ne>
* xmlschemas.c xmlstring.c: Fixed a segfault during
text concatenation when validating a node tree:
xmlStrncat was called with a @len of -1; but unlike
xmlStrncatNew, it does not calculate the length
automatically in such a case (reported by Judy Hay
on the mailing list).
Updated the descriptions of the involved string
functions to note this.
Thu Dec 15 12:11:07 CET 2005 Daniel Veillard <daniel@veillard.com> Thu Dec 15 12:11:07 CET 2005 Daniel Veillard <daniel@veillard.com>
* nanohttp.c: applied patch from Gary Coady to accept gzipped * nanohttp.c: applied patch from Gary Coady to accept gzipped

View File

@@ -26336,7 +26336,9 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
default: default:
break; break;
} }
} else { } else {
if (len < 0)
len = xmlStrlen(value);
/* /*
* Concat the value. * Concat the value.
*/ */

View File

@@ -437,7 +437,8 @@ xmlStrlen(const xmlChar *str) {
* @len: the length of @add * @len: the length of @add
* *
* a strncat for array of xmlChar's, it will extend @cur with the len * a strncat for array of xmlChar's, it will extend @cur with the len
* first bytes of @add. * first bytes of @add. Note that if @len < 0 then this is an API error
* and NULL will be returned.
* *
* Returns a new xmlChar *, the original @cur is reallocated if needed * Returns a new xmlChar *, the original @cur is reallocated if needed
* and should not be freed * and should not be freed
@@ -450,6 +451,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
if ((add == NULL) || (len == 0)) if ((add == NULL) || (len == 0))
return(cur); return(cur);
if (len < 0)
return(NULL);
if (cur == NULL) if (cur == NULL)
return(xmlStrndup(add, len)); return(xmlStrndup(add, len));
@@ -468,10 +471,11 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
* xmlStrncatNew: * xmlStrncatNew:
* @str1: first xmlChar string * @str1: first xmlChar string
* @str2: second xmlChar string * @str2: second xmlChar string
* @len: the len of @str2 * @len: the len of @str2 or < 0
* *
* same as xmlStrncat, but creates a new string. The original * same as xmlStrncat, but creates a new string. The original
* two strings are not freed. * two strings are not freed. If @len is < 0 then the length
* will be calculated automatically.
* *
* Returns a new xmlChar * or NULL * Returns a new xmlChar * or NULL
*/ */