Skip to content

Commit

Permalink
Fix phpGH-13603 ext/sockets: properly initialised address info data.
Browse files Browse the repository at this point in the history
Led to random characters visible on socket id on macOs.
  • Loading branch information
devnexen committed Mar 6, 2024
1 parent 33967ae commit 84a3367
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ PHP_FUNCTION(socket_read)
PHP_FUNCTION(socket_getsockname)
{
zval *arg1, *addr, *port = NULL;
php_sockaddr_storage sa_storage;
php_sockaddr_storage sa_storage = {0};
php_socket *php_sock;
struct sockaddr *sa;
struct sockaddr_in *sin;
Expand Down Expand Up @@ -994,7 +994,7 @@ PHP_FUNCTION(socket_getsockname)
PHP_FUNCTION(socket_getpeername)
{
zval *arg1, *arg2, *arg3 = NULL;
php_sockaddr_storage sa_storage;
php_sockaddr_storage sa_storage = {0};
php_socket *php_sock;
struct sockaddr *sa;
struct sockaddr_in *sin;
Expand Down
15 changes: 15 additions & 0 deletions ext/sockets/tests/gh13603.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GH-13603 - socket_getsockname - invalid characters
--EXTENSIONS--
sockets
--FILE--
<?php
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_bind($socket, 'sn.socp');
socket_listen($socket);
socket_getsockname($socket, $address);
var_dump($address);
socket_close($socket);
unlink($address);
--EXPECT--
string(7) "sn.socp"

0 comments on commit 84a3367

Please sign in to comment.