Re: com php-src: Fix bug #64330: NEWS ext/standard/tests/network/bug64330.phpt main/streams/xp_socket.c
| From: | Ferenc Kovacs | Date: | Tue, 08 Apr 2014 11:14:13 +0000 |
| Subject: | Re: com php-src: Fix bug #64330: NEWS ext/standard/tests/network/bug64330.phpt main/streams/xp_socket.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-76722@lists.php.net to get a copy of this message | ||
On Wed, Apr 2, 2014 at 11:09 AM, Michael Wallner <mike@php.net> wrote:
> Commit: 91a9d24aa30507e6c7d8937db2de24394f0ce121
> Author: Michael Wallner <mike@php.net> Wed, 2 Apr 2014
> 11:09:26 +0200
> Parents: f244513fc059a9b7ee2b91ad65f1a2f013b5d588
> Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
>
> Link:
>
> http://git.php.net/?p=php-src.git;a=commitdiff;h=91a9d24aa30507e6c7d8937db2de24394f0ce121
>
> Log:
> Fix bug #64330
>
> stream_socket_server() creates wrong Abstract Namespace UNIX sockets
>
> Bugs:
> https://bugs.php.net/64330
>
> Changed paths:
> M NEWS
> A ext/standard/tests/network/bug64330.phpt
> M main/streams/xp_socket.c
>
>
> Diff:
> diff --git a/NEWS b/NEWS
> index be9cf23..51ed4f3 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,6 +1,11 @@
> PHP
> NEWS
>
> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> ?? ??? 2014, PHP 5.4.28
> +
> +- Core:
> + . Fixed bug #64330 (stream_socket_server() creates wrong Abstract
> Namespace
> + UNIX sockets). (Mike)
> +
> - Embed:
> . Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol)
>
> diff --git a/ext/standard/tests/network/bug64330.phpt
> b/ext/standard/tests/network/bug64330.phpt
> new file mode 100644
> index 0000000..1ea305c
> --- /dev/null
> +++ b/ext/standard/tests/network/bug64330.phpt
> @@ -0,0 +1,20 @@
> +--TEST--
> +Bug #64330 (stream_socket_server() creates wrong Abstract Namespace UNIX
> sockets)
> +--SKIPIF--
> +<?php
> +if (!in_array("unix", stream_get_transports())) die("SKIP unix domain
> sockets unavailable");
> +?>
> +--FILE--
> +<?php
> +echo "Test\n";
> +$server = stream_socket_server("unix://\x00/MyBindName");
> +$client = stream_socket_client("unix://\x00/MyBindName");
> +if ($client) {
> + echo "ok\n";
> +}
> +?>
> +===DONE===
> +--EXPECT--
> +Test
> +ok
> +===DONE===
> diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
> index 2c7ca8d..53f0769 100644
> --- a/main/streams/xp_socket.c
> +++ b/main/streams/xp_socket.c
> @@ -588,7 +588,8 @@ static inline int php_tcp_sockop_bind(php_stream
> *stream, php_netstream_data_t *
>
> parse_unix_address(xparam, &unix_addr TSRMLS_CC);
>
> - return bind(sock->socket, (struct sockaddr *)&unix_addr,
> sizeof(unix_addr));
> + return bind(sock->socket, (const struct sockaddr
> *)&unix_addr,
> + (socklen_t) XtOffsetOf(struct sockaddr_un,
> sun_path) + xparam->inputs.namelen);
> }
> #endif
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi Mike,
this test fails for me on Mac OS X, based on a prompt search I think the
abstract unix socket is a linux-only feature:
http://man7.org/linux/man-pages/man7/unix.7.html
"Linux also supports an abstract namespace which is independent of the
filesystem."
https://bugs.php.net/bug.php?id=16121
http://www.freebsd.org/cgi/man.cgi?query=unix&apropos=0&sektion=0&manpath=FreeBSD+10.0-RELEASE&arch=default&format=html
As far as I can tell the patch itself doesn't require any modification as
it fails as I would try to open a non existent path:
002+
003+ Warning: stream_socket_server(): unable to connect to unix:// (Unknown
error) in
/Users/tyrael/checkouts/php-src.git/ext/standard/tests/network/bug64330.php
on line 3
004+
005+ Warning: stream_socket_client(): unable to connect to
unix://\0/MyBindName (No such file or directory) in
/Users/tyrael/checkouts/php-src.git/ext/standard/tests/network/bug64330.php
on line 4
002- ok
so I think the only thing needs fixing is adding a skipif for non
everything but linux.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu