#40894 [Asn->Csd]: fix for bug #38770 causes more harm than good on big-endian 64bit
ID: 40894
Updated by: iliaa@php.net
Reported By: mmarek at suse dot cz
-Status: Assigned
+Status: Closed
Bug Type: *Programming Data Structures
PHP Version: 5.2.1
Assigned To: iliaa
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-03-22 15:59:03] mmarek at suse dot cz
Description:
------------
Fix for bug #38770 breaks unpack() on big-endian 64bit, because it
reads uninitialized memory or memory that doesn't relate to the data
being processed.
In
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/pack.c?r1=1.62&r2=1.63
input[inputpos + machine_endian_long_map[3]] will read
input[inputpos+7] when unpacking 4 bytes.
Please revert the fix, as it tries to fix a questionable issue (-30000
simply doesn't fit into unsigned type) and causes trouble in cases where
it worked before (eg. pear is not even installable on POWER, b/c
install-pear-nozlib.phar makes heavy use of unpack()).
Reproduce code:
---------------
run
print_r( unpack( "V", pack( "V", 200 ) ));
several times on ppc64.
Expected result:
----------------
It should output
Array
(
[1] => 200
)
all the time.
Actual result:
--------------
# ./sapi/cli/php -r 'print_r( unpack( "V", pack( "V", 200 ) ));'
Array
(
[1] => 200
)
# ./sapi/cli/php -r 'print_r( unpack( "V", pack( "V", 200 ) ));'
Array
(
[1] => -2147483448
)
# ./sapi/cli/php -r 'print_r( unpack( "V", pack( "V", 200 ) ));'
Array
(
[1] => 200
)
# ./sapi/cli/php -r 'print_r( unpack( "V", pack( "V", 200 ) ));'
Array
(
[1] => 200
)
# ./sapi/cli/php -r 'print_r( unpack( "V", pack( "V", 200 ) ));'
Array
(
[1] => -2147483448
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40894&edit=1
Thread (3 messages)