Skip to content

Commit b3a1998

Browse files
author
Jason Greene
committed
@socket_recvfrom is now binary safe (Jason)
Zero the structure so that when the tcp layer of the OS decides to ignore it, we do not think we are getting a value
1 parent 936df3c commit b3a1998

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/sockets/sockets.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,12 +1392,13 @@ PHP_FUNCTION(socket_recvfrom)
13921392
zval_dtor(arg2);
13931393
zval_dtor(arg5);
13941394

1395-
ZVAL_STRING(arg2, recv_buf, 0);
1395+
ZVAL_STRINGL(arg2, recv_buf, retval, 0);
13961396
ZVAL_STRING(arg5, s_un.sun_path, 1);
13971397
break;
13981398

13991399
case AF_INET:
14001400
slen = sizeof(sin);
1401+
memset(&sin, 0, slen);
14011402
sin.sin_family = AF_INET;
14021403

14031404
if (arg6 == NULL) {
@@ -1418,7 +1419,7 @@ PHP_FUNCTION(socket_recvfrom)
14181419

14191420
address = inet_ntoa(sin.sin_addr);
14201421

1421-
ZVAL_STRING(arg2, recv_buf, 0);
1422+
ZVAL_STRINGL(arg2, recv_buf, retval, 0);
14221423
ZVAL_STRING(arg5, address ? address : "0.0.0.0", 1);
14231424
ZVAL_LONG(arg6, ntohs(sin.sin_port));
14241425
break;

0 commit comments

Comments
 (0)