1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/uri/tests/058.phpt
Tim Düsterhus 5e9080ff1b uri: Reject ports overflowing zend_long for uri_parser_rfc3986 (#19644)
RFC 3986 technically allows arbitrarily large integers as port numbers, but our
implementation is unable to deal with that, since it expects the port to fit
`zend_long`, reject those explicitly instead of misinterpreting them.
2025-08-31 14:45:31 +02:00

33 lines
787 B
PHP

--TEST--
Test that integer overflows in the port are rejected
--EXTENSIONS--
uri
--FILE--
<?php
if (PHP_INT_SIZE == 8) {
$uri = new \Uri\Rfc3986\Uri('https://example.com:9223372036854775807');
echo $uri->getPort(), PHP_EOL;
echo "2147483647", PHP_EOL;
} else {
$uri = new \Uri\Rfc3986\Uri('https://example.com:2147483647');
echo "9223372036854775807", PHP_EOL;
echo $uri->getPort(), PHP_EOL;
}
try {
if (PHP_INT_SIZE == 8) {
new \Uri\Rfc3986\Uri('https://example.com:9223372036854775808');
} else {
new \Uri\Rfc3986\Uri('https://example.com:2147483648');
}
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
9223372036854775807
2147483647
Uri\InvalidUriException: The port is out of range