com php-src: Bugfix #74556 stream_socket_get_name() returns empty string: NEWS ext/standard/streamsfun cs.c ext/standard/tests/streams/bug74556.phpt

From: Date: Sun, 28 May 2017 15:48:18 +0000
Subject: com php-src: Bugfix #74556 stream_socket_get_name() returns empty string: NEWS ext/standard/streamsfun cs.c ext/standard/tests/streams/bug74556.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-97913@lists.php.net to get a copy of this message
Commit: 8dcfec9789b4792f7b6b25673274b74bae71b512 Author: Sara Golemon <pollita@php.net> Sun, 28 May 2017 07:23:57 -0700 Parents: 6d2d0bbda7a406000ccb8a2dff86ddfe1ce467d5 Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8dcfec9789b4792f7b6b25673274b74bae71b512 Log: Bugfix #74556 stream_socket_get_name() returns empty string The original bug report had it returning '\0', but with a fix to abstract name handling (6d2d0bbda7) it now actually returns ''. Neither of these are good, as per unix(7) an empty socket name indicates an unbound name and "should not be inspected". Bugs: https://bugs.php.net/74556 Changed paths: M NEWS M ext/standard/streamsfuncs.c A ext/standard/tests/streams/bug74556.phpt Diff: diff --git a/NEWS b/NEWS index c51b14e..3c768ad 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ PHP NEWS - Core: . Fixed bug #74658 (Undefined constants in array properties result in broken properties). (Laruence) + . Fixed misparsing of abstract unix domain socket names. (Sara) - Opcache: . Fixed bug #74663 (Segfault with opcache.memory_protect and @@ -17,6 +18,9 @@ PHP NEWS - FTP: .. Fixed bug #74598 (ftp:// wrapper ignores context arg). (Sara) +- Streams: + . Fixed bug #74556 (stream_socket_get_name() returns '\0'). (Sara) + 8 Jun 2017 PHP 7.0.20 - Core: diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 0237ae8..877247e 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -314,6 +314,11 @@ PHP_FUNCTION(stream_socket_get_name) RETURN_FALSE; } + if (!ZSTR_LEN(name)) { + zend_string_release(name); + RETURN_FALSE; + } + RETVAL_STR(name); } /* }}} */ diff --git a/ext/standard/tests/streams/bug74556.phpt b/ext/standard/tests/streams/bug74556.phpt new file mode 100644 index 0000000..016a3dc --- /dev/null +++ b/ext/standard/tests/streams/bug74556.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #74556 stream_socket_get_name() on unix socket returns "\0" +--SKIPIF-- +<?php +if (!strncasecmp(PHP_OS, 'WIN', 3)) echo "skip Unix Only"; +--FILE-- +<?php + +$sock = __DIR__ . '/bug74556.sock'; +$s = stream_socket_server("unix://$sock"); +$c = stream_socket_client("unix://$sock"); + +var_dump( + stream_socket_get_name($s, true), + stream_socket_get_name($c, false) +); +--CLEAN-- +<?php +unlink(__DIR__ . '/bug74556.sock'); +--EXPECT-- +bool(false) +bool(false)

« previous php.cvs (#97913) next »