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/mbstring/tests/gh18901.phpt
Niels Dossche a5f21ca700 Fix GH-18901: integer overflow mb_split
We prevent signed overflow by making the count unsigned. The actual
interpretation of the count doesn't matter as it's just used to denote a
limit.

The test output for some limit values looks strange though, so that may
need extra investigation. However, that's orthogonal to this fix.

Closes GH-18906.
2025-06-22 13:07:43 +02:00

55 lines
701 B
PHP

--TEST--
GH-18901 (integer overflow mb_split)
--EXTENSIONS--
mbstring
--SKIPIF--
<?php
if (!function_exists('mb_split')) die('skip mb_split() not available');
?>
--FILE--
<?php
$vals = [PHP_INT_MIN, PHP_INT_MAX, -1, 0, 1];
foreach ($vals as $val) {
var_dump(mb_split('\d', '123', $val));
}
?>
--EXPECT--
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
string(0) ""
}
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
string(0) ""
}
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
string(0) ""
}
array(1) {
[0]=>
string(3) "123"
}
array(1) {
[0]=>
string(3) "123"
}