|  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
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.10 OS: Linux
Private report: No CVE-ID:
 [2012-04-18 13:32 UTC] pgajdos at suse dot com
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?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-20 07:47 UTC]
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:

$ php -r "print_r(unpack('H*', pack('I', -30000)));"
    [1] => d08affff
 [2012-04-20 07:47 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2012-04-23 21:11 UTC]
Automatic comment on behalf of cataphract
Log: Fixed bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64
 [2012-04-24 09:29 UTC]
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

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2012-04-24 09:29 UTC]
-Status: Assigned +Status: Closed
 [2012-04-24 09:46 UTC] pgajdos at suse dot com
Thanks for your quick fix.
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 03:02:48 2014 UTC