From: mmarek at suse dot cz Operating system: PHP version: 5.2.1 PHP Bug Type: *Programming Data Structures Bug description: fix for bug #38770 causes more harm than good on big-endian 64bit
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 bug report at http://bugs.php.net/?id=40894&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40894&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40894&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40894&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40894&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40894&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40894&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40894&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40894&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40894&r=support Expected behavior: http://bugs.php.net/fix.php?id=40894&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40894&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40894&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40894&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40894&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40894&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40894&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40894&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40894&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40894&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40894&r=mysqlcfg