Bug #80067 [NEW]: Omitting the port in bindto setting results in "Failed to parse address" error
From: me at derrabus dot de
Operating system: macOS 10.15
PHP version: 7.4.10
Package: Sockets related
Bug Type: Bug
Bug description:Omitting the port in bindto setting results in "Failed to parse address"
error
Description:
------------
Before php 7.4.10, it was possible to provide a "bindto" setting without
a port via the socket stream context. With 7.4.10, a warning is raised
and the stream is not opened.
This breaks Symfony's HttpClient component, see
https://github.com/symfony/symfony/issues/38081
for details.
The attached test script reproduces the regression. Executing it on php
7.4.9 produces the expected result. On php 7.4.10, the script fails. If
you change the "bindto" setting to "0:0", the script passes on both
versions, 7.4.9 and 7.4.10.
Test script:
---------------
<?php
$context = stream_context_create(['socket' => ['bindto' =>
'0']]);
var_dump(file_get_contents('https://httpbin.org/get', false,
$context));
Expected result:
----------------
string(200) "{
"args": {},
"headers": {
"Host": "httpbin.org"
},
"origin": "1.2.3.4",
"url": "https://httpbin.org/get"
}
Actual result:
--------------
Warning: file_get_contents(https://httpbin.org/get): failed to open
stream: Failed to parse address "0" in /app/test.php on line 4
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=80067&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80067&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80067&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80067&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80067&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80067&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80067&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80067&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80067&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80067&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80067&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80067&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80067&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80067&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80067&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80067&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80067&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80067&r=mysqlcfg
Thread (12 messages)
- me at derrabus dot de
- requinix@php.netBug #80067 [Opn->Fbk]: Omitting the port in bindto setting results in "Failed to parse address" error
- me at derrabus dot deBug #80067 [Com]: Omitting the port in bindto setting results in "Failed to parse address" error
- nikic@php.netBug #80067 [Fbk]: Omitting the port in bindto setting results in "Failed to parse address" error
- requinix@php.netBug #80067 [Fbk->Opn]: Omitting the port in bindto setting results in "Failed to parse address" error
- twosee@php.netBug #80067 [Opn]: Omitting the port in bindto setting results in "Failed to parse address" error
- me at derrabus dot deBug #80067 [Opn]: Omitting the port in bindto setting results in "Failed to parse address" error
- requinix@php.netBug #80067 [Opn]: Omitting the port in bindto setting results in "Failed to parse address" error
- me at derrabus dot deBug #80067 [Opn]: Omitting the port in bindto setting results in "Failed to parse address" error
- cmb@php.netBug #80067 [PATCH]: Omitting the port in bindto setting results in "Failed to parse address" error
- cmb@php.netBug #80067 [Asn->Csd]: Omitting the port in bindto setting results in "Failed to parse address" error
- me at derrabus dot deBug #80067 [Csd]: Omitting the port in bindto setting results in "Failed to parse address" error