php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61764 output of unpack while 'I' used
Submitted: 2012-04-18 13:32 UTC Modified: 2012-04-24 09:46 UTC
From: pgajdos at suse dot com Assigned: cataphract (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.10 OS: Linux
Private report: No CVE-ID: None
 [2012-04-18 13:32 UTC] pgajdos at suse dot com
Description:
------------
php -r "print_r(unpack('I', pack('I', -30000)));

gives 4294937296 on s390x but -30000 on x86_64. According to manual I think correct value should be 4294937296 on x86_64. Also perl returns this number for
perl -e "print unpack('I', pack('I', -30000))" for these two architectures.

Or have I misunderstood something?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-20 07:47 UTC] cataphract@php.net
Verified. If PHP can represent the unpacked unsigned number with its integer type, it should never return a negative number.

The result of pack() is correct:

http://www.wolframalpha.com/input/?i=%28-30000+mod+2%5E32%29+in+hex

ffff8ad0_16
$ php -r "print_r(unpack('H*', pack('I', -30000)));"
Array
(
    [1] => d08affff
)
 [2012-04-20 07:47 UTC] cataphract@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2012-04-23 21:11 UTC] cataphract@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8d748e5de519867d9b6ce40e3ea28a209b07768f
Log: Fixed bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64
 [2012-04-24 09:29 UTC] cataphract@php.net
This bug has been fixed in SVN.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-24 09:29 UTC] cataphract@php.net
-Status: Assigned +Status: Closed
 [2012-04-24 09:46 UTC] pgajdos at suse dot com
Thanks for your quick fix.
 [2014-10-07 23:26 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=8d748e5de519867d9b6ce40e3ea28a209b07768f
Log: Fixed bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64
 [2014-10-07 23:37 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=8d748e5de519867d9b6ce40e3ea28a209b07768f
Log: Fixed bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 10:01:28 2024 UTC