mirror of
https://github.com/php/php-src.git
synced 2024-10-04 00:06:16 +00:00
dbc5b42435
Made pack() with "Z" force NUL termination, even if it mean truncating input to less than the number of characters specified and if the number of characters is "*", the output will be one byte larger than the input. Improved tests.
27 lines
459 B
PHP
27 lines
459 B
PHP
--TEST--
|
|
Bug #61038: unpack("a5", "str\0\0") does not work as expected
|
|
--FILE--
|
|
<?php
|
|
var_dump(unpack("a4", "str\0\0"));
|
|
var_dump(unpack("a5", "str\0\0"));
|
|
var_dump(unpack("a6", "str\0\0"));
|
|
var_dump(unpack("a*", "str\0\0"));
|
|
?>
|
|
--EXPECTF--
|
|
array(1) {
|
|
[1]=>
|
|
string(4) "str%c"
|
|
}
|
|
array(1) {
|
|
[1]=>
|
|
string(5) "str%c%c"
|
|
}
|
|
|
|
Warning: unpack(): Type a: not enough input, need 6, have 5 in %s on line %d
|
|
bool(false)
|
|
array(1) {
|
|
[1]=>
|
|
string(5) "str%c%c"
|
|
}
|
|
|