php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26170 ip2long() fails if IP begins with a 0 (zero)
Submitted: 2003-11-07 20:05 UTC Modified: 2003-11-08 05:15 UTC
From: phpbugspam at netebb dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0b2 (beta2) OS: Windows 2000 SP4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpbugspam at netebb dot com
New email:
PHP Version: OS:

 

 [2003-11-07 20:05 UTC] phpbugspam at netebb dot com
Description:
------------
Line 4 (09.0.0.0) fails in the following code.

Fails on both 4.3.4 and 5.0.0b2.

Haven't tried it in *nix.

Thanks,

Ross

Reproduce code:
---------------
<?php
ini_set('html_errors', false);
assert(ip2long('1.0.0.0') == ip2long('01.0.0.0'));
assert(ip2long('9.0.0.0') == ip2long('09.0.0.0'));
echo 'phpversion=',phpversion();
?>


Expected result:
----------------
Nothing.

Actual result:
--------------
$ php -q bug_ip2long.php 

Warning: assert(): Assertion failed in c:\ross\freebeer\www\demo\bug_ip2long.php on line 4
phpversion=4.3.4

$ php -q bug_ip2long.php 

Warning: assert(): Assertion failed in c:\ross\freebeer\www\demo\bug_ip2long.php on line 4
phpversion=5.0.0b2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-07 21:37 UTC] pollita@php.net
Unable to confirm.

Works locally on Win2K/SP4, Linux 2.4.22, and FreeBSD 5.1
 [2003-11-08 05:15 UTC] wez@php.net
Numbers starting with 0 are treated as octal; 09 is invalid octal.
[This is a feature of the socket libraries on most OS,
and is not PHP specific]

Solution: don't use numbers with leading 0's
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 12 21:01:27 2024 UTC