Files
php-src/ext/xmlreader/tests/oom_xmlreader_getattribute.phpt
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00

33 lines
803 B
PHP

--TEST--
XMLReader::getAttribute() doesn't reach hard limit
--EXTENSIONS--
xmlreader
--INI--
memory_limit=2M
--FILE--
<?php
$path = __DIR__ . '/' . basename(__FILE__, '.php') . '.tmp';
$fp = fopen($path, 'wb');
/* A single 6 MB attribute value, written in chunks so building the
* document stays inside the soft limit. */
$chunk = str_repeat("x", 512 * 1024);
fwrite($fp, "<r a=\"");
for ($i = 0; $i < 12; $i++) {
fwrite($fp, $chunk);
}
fwrite($fp, "\"/>");
unset($chunk);
fclose($fp);
$reader = XMLReader::open($path);
$reader->read();
$reader->getAttribute("a");
echo "not reached\n";
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tmp');
?>
--EXPECTF--
Fatal error: Allowed memory size of 2097152 bytes exhausted %S(tried to allocate %d bytes) in %s on line %d