iliaa Thu Jan 26 15:48:15 2006 UTC Modified files: /php-src/ext/standard/tests/strings bug36148.phpt /php-src/ext/standard pack.c Log: MFB51: Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to the end of the string). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/strings/bug36148.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/bug36148.phpt diff -u /dev/null php-src/ext/standard/tests/strings/bug36148.phpt:1.2 --- /dev/null Thu Jan 26 15:48:15 2006 +++ php-src/ext/standard/tests/strings/bug36148.phpt Thu Jan 26 15:48:15 2006 @@ -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" +} http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/pack.c?r1=1.60&r2=1.61&diff_format=u Index: php-src/ext/standard/pack.c diff -u php-src/ext/standard/pack.c:1.60 php-src/ext/standard/pack.c:1.61 --- php-src/ext/standard/pack.c:1.60 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/pack.c Thu Jan 26 15:48:15 2006 @@ -15,7 +15,7 @@ | Author: Chris Schneider <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: pack.c,v 1.60 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: pack.c,v 1.61 2006/01/26 15:48:15 iliaa Exp $ */ #include "php.h" @@ -692,7 +692,9 @@ len = size * 2; } - len -= argb % 2; + if (argb > 0) { + len -= argb % 2; + } buf = emalloc(len + 1);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php