Fix #79971: special character is breaking the path in xml function

The libxml based XML functions accepting a filename actually accept
URIs with possibly percent-encoded characters.  Percent-encoded NUL
bytes lead to truncation, like non-encoded NUL bytes would.  We catch
those, and let the functions fail with a respective warning.
This commit is contained in:
Christoph M. Becker 2020-09-01 10:04:28 +02:00 committed by Stanislav Malyshev
parent 88f99c9c1d
commit f15f8fc573
No known key found for this signature in database
GPG key ID: 94B3CB48C3ECA219
5 changed files with 63 additions and 0 deletions

View file

@ -112,6 +112,11 @@ PHP_METHOD(domimplementation, createDocumentType)
pch2 = (xmlChar *) systemid;
}
if (strstr(name, "%00")) {
php_error_docref(NULL, E_WARNING, "URI must not contain percent-encoded NUL bytes");
RETURN_FALSE;
}
uri = xmlParseURI(name);
if (uri != NULL && uri->opaque != NULL) {
localname = xmlStrdup((xmlChar *) uri->opaque);