ID:          40894
 Updated by:  [EMAIL PROTECTED]
 Reported By: mmarek at suse dot cz
-Status:      Open
+Status:      Assigned
 Bug Type:    *Programming Data Structures
 PHP Version: 5.2.1
-Assigned To: 
+Assigned To: iliaa


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

Reply via email to