mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
MFB51: Fixed bug #36148 (unpack("H*hex", $data) is adding an extra
character to the end of the string).
This commit is contained in:
parent
98ca921fb2
commit
b031ac3fe4
2 changed files with 32 additions and 1 deletions
|
@ -692,7 +692,9 @@ PHP_FUNCTION(unpack)
|
|||
len = size * 2;
|
||||
}
|
||||
|
||||
if (argb > 0) {
|
||||
len -= argb % 2;
|
||||
}
|
||||
|
||||
buf = emalloc(len + 1);
|
||||
|
||||
|
|
29
ext/standard/tests/strings/bug36148.phpt
Normal file
29
ext/standard/tests/strings/bug36148.phpt
Normal file
|
@ -0,0 +1,29 @@
|
|||
--TEST--
|
||||
Bug #36148 (unpack("H*hex", $data) is adding an extra character to the end of the string)
|
||||
--FILE--
|
||||
<?php
|
||||
$values = array("a", "aa", "aaa", "aaaa");
|
||||
foreach ($values as $value) {
|
||||
$a = pack("H*", $value);
|
||||
$b = unpack("H*", $a);
|
||||
echo $value.": ";
|
||||
var_dump($b);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
a: array(1) {
|
||||
[1]=>
|
||||
string(2) "a0"
|
||||
}
|
||||
aa: array(1) {
|
||||
[1]=>
|
||||
string(2) "aa"
|
||||
}
|
||||
aaa: array(1) {
|
||||
[1]=>
|
||||
string(4) "aaa0"
|
||||
}
|
||||
aaaa: array(1) {
|
||||
[1]=>
|
||||
string(4) "aaaa"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue