From:
Operating system: Linux
PHP version: 5.3.3
Package: Unknown/Other Function
Bug Type: Bug
Bug description:unpack() format I, L, N and V returns negative value
Description:
------------
According to the documentation, all I, L, N and V formats are defined to be
unsigned integer. On my Linux(32bit intel), unpacking FFFFFF returns -1. As
you
can see the test script, we automatically use float for large integer. So
the
result should be float(4294967295), otherwise we get wrong number of -1.
Test script:
---------------
<?php
var_dump(unpack("I","\xFF\xFF\xFF\xFF"));
var_dump(unpack("L","\xFF\xFF\xFF\xFF"));
var_dump(unpack("N","\xFF\xFF\xFF\xFF"));
var_dump(unpack("V","\xFF\xFF\xFF\xFF"));
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_SIZE);
var_dump(4294967295);
Expected result:
----------------
array(1) {
[1]=>
float(4294967295)
}
array(1) {
[1]=>
float(4294967295)
}
array(1) {
[1]=>
float(4294967295)
}
array(1) {
[1]=>
float(4294967295)
}
int(2147483647)
int(4)
float(4294967295)
Actual result:
--------------
array(1) {
[1]=>
int(-1)
}
array(1) {
[1]=>
int(-1)
}
array(1) {
[1]=>
int(-1)
}
array(1) {
[1]=>
int(-1)
}
int(2147483647)
int(4)
float(4294967295)
--
Edit bug report at http://bugs.php.net/bug.php?id=52729&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52729&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52729&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52729&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52729&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52729&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52729&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52729&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52729&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52729&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52729&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52729&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52729&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52729&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52729&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52729&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52729&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52729&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52729&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52729&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52729&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52729&r=mysqlcfg