Bug #74556 [Com]: stream_socket_get_name returns \0 string instead of false

From: Date: Thu, 21 Dec 2017 18:40:58 +0000
Subject: Bug #74556 [Com]: stream_socket_get_name returns \0 string instead of false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213225@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74556&edit=1 ID: 74556 Comment by: kelunik@php.net Reported by: cpuidle at gmx dot de Summary: stream_socket_get_name returns \0 string instead of false Status: Re-Opened Type: Bug Package: Streams related Operating System: macOS PHP Version: 7.1.7 Assigned To: pollita Block user comment: N Private report: N New Comment: Yes. Until there's a better fix available, it's probably better to revert the fix for now, at least for Linux (as abstract socket namespace is Linux specific IIRC). Has this been reported to Apple? I guess it should really be fixed there? Previous Comments: ------------------------------------------------------------------------ [2017-12-21 17:53:37] pollita@php.net > string(15) "" > Ugh, wait, no... you're right. That's a whole chunk of null bytes, isn't it? Okay, I'm less keen on masking this behavior since the standard says that a leading null byte indicates abstract namespace with the following bytes providing the abstract identifier where "null bytes have no significance", which on a strict reading says that the "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" output reported in this original bug is a valid indicator. (Even if it's probably nonsensical.) ------------------------------------------------------------------------ [2017-12-19 23:19:24] pollita@php.net No, MacOS returns a single null byte which is nonsensical according to POSIX. ------------------------------------------------------------------------ [2017-12-19 22:08:49] kelunik@php.net If I got it right then macOS returned multiple NUL-bytes? So that'd not work. ------------------------------------------------------------------------ [2017-12-19 18:02:29] pollita@php.net Hrmmm.... Multiple layered things here. How about: if ((ZSTR_LEN(name) == 0) || ((ZSTR_LEN(name) == 1) && (ZSTR_VAL(name)[0] == 0))) { zend_string_release(name); RETURN_FALSE; } That would return anything using an actual abstract socket path "\0/tmp/foo" but deal with the case where Mac returns "\0" for an unbound name, ------------------------------------------------------------------------ [2017-12-18 00:12:43] kelunik@php.net The provided fix is incomplete / wrong. It breaks sockets using the abstract socket namespace on Linux. https://3v4l.org/RtaV2 ------------------------------------------------------------------------ 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=74556 -- Edit this bug report at https://bugs.php.net/bug.php?id=74556&edit=1

« previous php.bugs (#213225) next »