php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26667 ip2long("") = 0 intstead of -1
Submitted: 2003-12-19 06:22 UTC Modified: 2003-12-19 08:30 UTC
From: ovdspek at liacs dot nl Assigned:
Status: Closed Package: Network related
PHP Version: 4CVS-2003-12-18 OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 6 = ?
Subscribe to this entry?

 
 [2003-12-19 06:22 UTC] ovdspek at liacs dot nl
Description:
------------
ip2long returns 0 if the input is an empty string. However, an empty string is not valid, so it should return -1.

"The function ip2long() generates an IPv4 Internet network address from its Internet standard format (dotted string) representation. If ip_address is invalid than -1 is returned. Note that -1 does not evaluate as FALSE in PHP."

Reproduce code:
---------------
<?php echo ip2long(""); ?>

Expected result:
----------------
-1

Actual result:
--------------
0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-19 06:41 UTC] derick@php.net
hmm, works for me:

derick@kossu:~$ php-4.3dev -r 'echo ip2long(""); '
-1
 [2003-12-19 07:03 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Okay, then please try the latest version :)
 [2003-12-19 07:05 UTC] ovdspek at liacs dot nl
D:\Temp>php ..\wte\php\a.php
Content-type: text/html
X-Powered-By: PHP/4.3.5-dev

0
 [2003-12-19 08:30 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC