From: Ilia Alshanetsky Date: Tue, 12 May 2009 12:34:55 +0000 (+0000) Subject: Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns wrong X-Git-Tag: php-5.3.0RC3~281 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3e3d607b4506e7416fd9a436ecce6434327fda4;p=php Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns wrong result) --- diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 375ebe42d0..4d12c75ac3 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -784,6 +784,13 @@ PHP_FUNCTION(unpack) } v |= php_unpack(&input[inputpos], 4, issigned, map); + if (sizeof(long) > 4) { + if (type == 'l') { + v = (signed int) v; + } else { + v = (unsigned int) v; + } + } add_assoc_long(return_value, n, v); break; } diff --git a/ext/standard/tests/strings/bug38770.phpt b/ext/standard/tests/strings/bug38770.phpt index 2494a911bd..75522ee9d5 100644 --- a/ext/standard/tests/strings/bug38770.phpt +++ b/ext/standard/tests/strings/bug38770.phpt @@ -12,7 +12,7 @@ echo "Done\n"; --EXPECT-- Array ( - [1] => -30000 + [1] => 4294937296 ) Array (