Bug #75715 [Opn->Fbk]: ip2long
| From: | levim@php.net | Date: | Thu, 21 Dec 2017 16:13:20 +0000 |
| Subject: | Bug #75715 [Opn->Fbk]: ip2long | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213216@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75715&edit=1
ID: 75715
Updated by: levim@php.net
Reported by: igronus at gmail dot com
Summary: ip2long
-Status: Open
+Status: Feedback
Type: Bug
Package: Unknown/Other Function
PHP Version: 7.1.12
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2017-12-21 16:10:27] levim@php.net
According to https://serverfault.com/a/10989/100096:
> It depends on the subnet of the IP address in question. In general, the first and last
> addresses in a subnet are used as the network identifier and broadcast address, respectively. All
> other addresses in the subnet can be assigned to hosts on that subnet.
> For example, IP addresses of networks with subnet masks of at least 24 bits ending in .0 or
> .255 can never be assigned to hosts. Such "last" addresses of a subnet are considered
> "broadcast" addresses and all hosts on the corresponding subnet will respond to it.
> Theoretically, there could be situations where you can assign an address ending in .0: for
> example, if you have a subnet like 192.168.0.0/255.255.0.0, you are allowed to assign a host the
> address 192.168.1.0. It could create confusion though, so it's not a very common practice.
> In your example 10.6.43.0 with subnet 255.255.252.0 (22 bit subnet mask)
means subnet ID 10.6.40.0, a host address range from 10.6.40.1 to 10.6.43.254 and a broadcast
address 10.6.43.255. So in theory, your example 10.6.43.0 would be allowed as a valid host address.
Server Fault is not necessarily authoritative and I am not a subject expert. Can you provide a link
to an RFC or some other authoritative source indicating it is not permitted? Otherwise I will close
this as not-a-bug.
------------------------------------------------------------------------
[2017-12-21 16:01:26] igronus at gmail dot com
Description:
------------
Function ip2long (and filter_var with second argument FILTER_VALIDATE_IP too) doesn't return
false when argument is ip-address with zero in last octet (127.0.0.0 for example). However this
argument is non-valid ip-address.
Test script:
---------------
$ip = '192.168.0.0';
var_dump(ip2long($ip));
var_dump(filter_var($ip, FILTER_VALIDATE_IP));
Expected result:
----------------
It must return false in both cases.
Actual result:
--------------
int(3232235520)
string(11) "192.168.0.0"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75715&edit=1