From: phpbug at labres dot at
Operating system: Linux (debian woody)
PHP version: 4.3.4
PHP Bug Type: Math related
Bug description: ip2long() calculates networks (partial ip addr.) wrong
Description:
------------
When given network addresses (partial ip addresses)*),
ip2long() calculates erratic values:
Input Output dechex should be
192 int(192) c0 c0000000
192.168 int(-1073741656) c00000a8 c0a80000
192.168.1 int(-1062731775) c0a80001 c0a80100
*) you will need this to convert 192/8, 192.168/16 etc
network addresses.
Reproduce code:
---------------
$net=ip2long("192");
echo dechex($net)."\n";
$net=ip2long("192.168");
echo dechex($net)."\n";
$net=ip2long("192.168.1");
echo dechex($net)."\n";
Expected result:
----------------
c0000000
c0a80000
c0a80100
Actual result:
--------------
c0
c00000a8
c0a80001
--
Edit bug report at http://bugs.php.net/?id=27710&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27710&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27710&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27710&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27710&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27710&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27710&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27710&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27710&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27710&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27710&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27710&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27710&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27710&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27710&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27710&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27710&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27710&r=float