From:             laacz at laacz dot lv
Operating system: 6.1-STABLE FreeBSD (amd64)
PHP version:      5.2.9
PHP Bug Type:     Strings related
Bug description:  unpacking unsigned long 32bit bit endian returns wrong result

Description:
------------
Unpacking unsigned long (32bit; always big endian; "N") on 64bit 
system returns 64bit signed int instead of 32bit.

You can do & 0xffffffff on unpacked value, and get desired result, 
but that's still a bug.

Reproduce code:
---------------
<?php
list(,$command_id) =  unpack('N', chr(0x80) . chr(0x00) . chr(0x00) .
chr(0x09));
echo hexdec(dechex($command_id)) . "\n0x" . dechex($command_id) . "\n";
?>



Expected result:
----------------
2147483657
0x80000009





Actual result:
--------------
1.8446744071562E+19
0xffffffff80000009





-- 
Edit bug report at http://bugs.php.net/?id=47564&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47564&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47564&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47564&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47564&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47564&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47564&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47564&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47564&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47564&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47564&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47564&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47564&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47564&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47564&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47564&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47564&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47564&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47564&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47564&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47564&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47564&r=mysqlcfg

Reply via email to