From 8dcfec9789b4792f7b6b25673274b74bae71b512 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sun, 28 May 2017 07:23:57 -0700 Subject: [PATCH] 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". --- NEWS | 4 ++++ ext/standard/streamsfuncs.c | 5 +++++ ext/standard/tests/streams/bug74556.phpt | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 ext/standard/tests/streams/bug74556.phpt diff --git a/NEWS b/NEWS index c51b14ec6af..3c768adad1d 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 0237ae8eb7e..877247e8ebc 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 00000000000..016a3dce863 --- /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-- +