Edit report at https://bugs.php.net/bug.php?id=80067&edit=1
ID: 80067
Updated by: requinix@php.net
Reported by: me at derrabus dot de
Summary: Omitting the port in bindto setting results in
"Failed to parse address" error
Status: Open
Type: Bug
Package: Sockets related
Operating System: macOS 10.15
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
> If that zero is too obscure, we can do the same with an actual IP address
> assigned to the machine you're running the code on,
Except that has a different meaning. I don't think there are too many good cases for binding to
all interfaces either, but PHP shouldn't disallow it just because it could be misused.
Previous Comments:
------------------------------------------------------------------------
[2020-09-07 08:40:40] me at derrabus dot de
> But I donât think it is a good practice to use "0"
Probably. If that zero is too obscure, we can do the same with an actual IP address assigned to the
machine you're running the code on, like 192.168.0.1 for example.
* Setting bindto to "192.168.0.1:0" will work on 7.4.9 and 7.4.10.
* Setting bindto to "192.168.0.1" will work on 7.4.9 and break on 7.4.10.
So, omitting the port is what isn't possible anymore.
------------------------------------------------------------------------
[2020-09-07 03:18:13] twosee@php.net
It is indeed caused by https://github.com/php/php-src/pull/5903 ...
As a bugfix, the patch is correct, I think.
If we want to revert it to the previous behavior, we should change the implementation of
parse_ip_address_ex instead of reverting the patch.
But I donât think it is a good practice to use "0"...
------------------------------------------------------------------------
[2020-09-06 22:28:11] requinix@php.net
> So my understanding is, I can provide either just the IP address or just the
> port or both.
We could blame poor phrasing on the docs' part, but the very next sentence says:
> The syntax is ip:port for IPv4 addresses, and [ip]:port for IPv6 addresses.
To me, that indicates a specification which will supersede just about anything else that might be
stated.
This is also when I notice that I totally misunderstood that second syntax. The [] brackets are
required because it's for IPv6 - they don't mean the address half is optional.
So actually, according to the docs, the two syntaxes would be "0:0" for IPv4 and
"[0]:0" for IPv6.
Not saying that "0" / "[0]" and ":0" / "[]:0" should not be
allowed; I don't care either way, though I don't see why they shouldn't be. I'm
just questioning why Symfony was relying on undocumented behavior.
Naturally, assuming this break does get fixed, the docs need to be updated.
------------------------------------------------------------------------
[2020-09-06 21:57:36] nikic@php.net
Possibly caused by https://github.com/php/php-src/pull/5903.
------------------------------------------------------------------------
[2020-09-06 21:49:18] me at derrabus dot de
> The documentation doesn't actually say that "0" is allowed.
Your quote says:
> the IP address (either IPv4 or IPv6) and/or the port number
So my understanding is, I can provide either just the IP address or just the port or both. Omitting
the port seems valid to me. Your suggestion ":0" also triggers a warning by the way,
although the actual operation succeeds.
But this discussion is a bit beside the point: if providing the port had always been mandatory, I
would not file a bug ticket here. But it wasn't until recently. My point is that this change is
quite heavy for a bugfix release and it breaks a widely used library.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80067
--
Edit this bug report at https://bugs.php.net/bug.php?id=80067&edit=1