Skip to content

Commit e628ee9

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Bugfix #74556 stream_socket_get_name() returns empty string Fix abstract name handling to be binary safe
2 parents d9458aa + 8dcfec9 commit e628ee9

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55
- Core:
66
. Fixed bug #74658 (Undefined constants in array properties result in broken
77
properties). (Laruence)
8+
. Fixed misparsing of abstract unix domain socket names. (Sara)
89

910
- Opcache:
1011
. Fixed bug #74663 (Segfault with opcache.memory_protect and
@@ -17,6 +18,9 @@ PHP NEWS
1718
- FTP:
1819
. Fixed bug #74598 (ftp:// wrapper ignores context arg). (Sara)
1920

21+
- Streams:
22+
. Fixed bug #74556 (stream_socket_get_name() returns '\0'). (Sara)
23+
2024
8 Jun 2017, PHP 7.1.6
2125

2226
- Core:

ext/standard/streamsfuncs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ PHP_FUNCTION(stream_socket_get_name)
314314
RETURN_FALSE;
315315
}
316316

317+
if (!ZSTR_LEN(name)) {
318+
zend_string_release(name);
319+
RETURN_FALSE;
320+
}
321+
317322
RETVAL_STR(name);
318323
}
319324
/* }}} */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #74556 stream_socket_get_name() on unix socket returns "\0"
3+
--SKIPIF--
4+
<?php
5+
if (!strncasecmp(PHP_OS, 'WIN', 3)) echo "skip Unix Only";
6+
--FILE--
7+
<?php
8+
9+
$sock = __DIR__ . '/bug74556.sock';
10+
$s = stream_socket_server("unix://$sock");
11+
$c = stream_socket_client("unix://$sock");
12+
13+
var_dump(
14+
stream_socket_get_name($s, true),
15+
stream_socket_get_name($c, false)
16+
);
17+
--CLEAN--
18+
<?php
19+
unlink(__DIR__ . '/bug74556.sock');
20+
--EXPECT--
21+
bool(false)
22+
bool(false)

main/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
661661

662662
if (ua->sun_path[0] == '\0') {
663663
/* abstract name */
664-
int len = strlen(ua->sun_path + 1) + 1;
664+
int len = sl - sizeof(sa_family_t);
665665
*textaddr = zend_string_init((char*)ua->sun_path, len, 0);
666666
} else {
667667
int len = strlen(ua->sun_path);

0 commit comments

Comments
 (0)