1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-10-24 01:09:01 +03:00

fix: add length check to xmlURIEscapeStr in uri.c

Commit 538b2e38 fixed xmlBuildRelativeURISafe for the pattern where
xmlStrlen() returns 0 for strings longer than INT_MAX, but
xmlURIEscapeStr was not fixed. Without the check, len = 0 + 20, and
the write loop eventually overflows via int wrapping of the out counter.

Add a return NULL guard when xmlStrlen returns 0.
This commit is contained in:
mohammadmseet-hue
2026-04-16 02:54:30 +02:00
committed by Daniel Garcia Moreno
parent e41032ae9f
commit b9da8bcc78

2
uri.c
View File

@@ -1644,6 +1644,8 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
if (str[0] == 0)
return(xmlStrdup(str));
len = xmlStrlen(str);
if (len == 0)
return(NULL);
len += 20;
ret = xmlMalloc(len);