Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix #73246: XMLReader: encoding length not checked
This commit is contained in:
Christoph M. Becker 2021-05-03 12:30:29 +02:00
commit 768e8b8319
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
2 changed files with 26 additions and 0 deletions

View File

@ -860,6 +860,11 @@ PHP_METHOD(XMLReader, open)
RETURN_THROWS();
}
if (encoding && CHECK_NULL_PATH(encoding, encoding_len)) {
php_error_docref(NULL, E_WARNING, "Encoding must not contain NUL bytes");
RETURN_FALSE;
}
valid_file = _xmlreader_get_valid_file_path(source, resolved_path, MAXPATHLEN );
if (valid_file) {
@ -1035,6 +1040,11 @@ PHP_METHOD(XMLReader, XML)
RETURN_THROWS();
}
if (encoding && CHECK_NULL_PATH(encoding, encoding_len)) {
php_error_docref(NULL, E_WARNING, "Encoding must not contain NUL bytes");
RETURN_FALSE;
}
inputbfr = xmlParserInputBufferCreateMem(source, source_len, XML_CHAR_ENCODING_NONE);
if (inputbfr != NULL) {

View File

@ -0,0 +1,16 @@
--TEST--
Bug #73246 (XMLReader: encoding length not checked)
--SKIPIF--
<?php
if (!extension_loaded("xmlreader")) die("skip xmlreader extension not available");
?>
--FILE--
<?php
$reader = new XMLReader();
$reader->open(__FILE__, "UTF\0-8");
$reader->XML('<?xml version="1.0"?><root/>', "UTF\0-8");
?>
--EXPECTF--
Warning: XMLReader::open(): Encoding must not contain NUL bytes in %s on line %d
Warning: XMLReader::XML(): Encoding must not contain NUL bytes in %s on line %d