Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ext/xmlreader/php_xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,11 @@ PHP_METHOD(xmlreader, open)
RETURN_FALSE;
}

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) {
Expand Down Expand Up @@ -1055,6 +1060,11 @@ PHP_METHOD(xmlreader, XML)
RETURN_FALSE;
}

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) {
Expand Down
16 changes: 16 additions & 0 deletions ext/xmlreader/tests/bug73246.phpt
Original file line number Diff line number Diff line change
@@ -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