Skip to content

Commit

Permalink
Fix GH-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.

Close GH-13606
  • Loading branch information
devnexen committed Mar 6, 2024
1 parent 33967ae commit e3f0d03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ PHP NEWS
. Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with
unknown modes). (timwolla)

- Sockets:
. Fixed bug GH-13604 (socket_getsockname returns random characters in the
end of the socket name). (David Carlier)

- SPL:
. Fixed bug GH-13531 (Unable to resize SplfixedArray after being unserialized
in PHP 8.2.15). (nielsdos)
Expand Down
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 e3f0d03

Please sign in to comment.