|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51920 ip2long result depends on platform
Submitted: 2010-05-26 12:39 UTC Modified: 2010-05-27 09:41 UTC
From: olafvdspek at gmail dot com Assigned:
Status: Not a bug Package: Network related
PHP Version: 5.3.2 OS: Debian x64
Private report: No CVE-ID: None
 [2010-05-26 12:39 UTC] olafvdspek at gmail dot com
The result of ip2long depends on the plaform. It shouldn't.

Test script:
echo ip2long('');

x86: -1073732954
x64: 3221234342

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 12:42 UTC]
-Status: Open +Status: Bogus
 [2010-05-26 12:42 UTC]
See the example in the PHP manual to know how to print out unsigned integer.
 [2010-05-26 12:45 UTC] olafvdspek at gmail dot com
I know how to print an uint, that's not my question!
 [2010-05-26 13:10 UTC]
So what are you asking then? That's exactly what you are experiencing. There is no bug.
 [2010-05-26 13:11 UTC] olafvdspek at gmail dot com
I'm asking for ip2long to return the same (negative) values on all platforms.
 [2010-05-26 15:06 UTC]
So no, you don't know what an unsigned integer value is. Please ask support in one of the numerous php support channels.
 [2010-05-26 15:25 UTC] olafvdspek at gmail dot com
I know perfectly well what an unsigned int is.
 [2010-05-26 17:13 UTC]
So what are you requesting? That ip2long returns a string representation of the 
number, or a float? Of which value 3221234342 or -107373295?
 [2010-05-26 17:16 UTC] olafvdspek at gmail dot com
Returning -107373295 on x64 would make it consistent with x86.

But people might prefer 3221234342, in which case it could be returned as a string.
 [2010-05-26 23:26 UTC]
This would be a different binary representation, which breaks binary math, which people often do with IP addresses.
 [2010-05-26 23:28 UTC] olafvdspek at gmail dot com
Then just return the negative value.
 [2010-05-27 08:25 UTC]
Please read up on that topic and stop complaining about nothing.
You may start here or anywhere else:
 [2010-05-27 09:41 UTC] olafvdspek at gmail dot com
Like I said before, I know what signed and unsigned shorts, ints, longs and long longs are.
 [2010-06-13 19:55 UTC] artificial at iol dot ie
This is why I peruse for the lulz when somebody submits a bogus bug and makes themself look stupid.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 01:03:39 2021 UTC