Skip to content

Commit d466fba

Browse files
committed
ext/sockets: socket_recvfrom() improve error message when port argument is missing
1 parent dae11b3 commit d466fba

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

ext/sockets/sockets.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,8 @@ PHP_FUNCTION(socket_recvfrom)
15801580

15811581
if (arg6 == NULL) {
15821582
zend_string_efree(recv_buf);
1583-
WRONG_PARAM_COUNT;
1583+
zend_argument_value_error(6, "must be specified when argument #1 ($socket) is of type AF_INET or AF_INET6");
1584+
RETURN_THROWS();
15841585
}
15851586

15861587
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen);
@@ -1607,7 +1608,8 @@ PHP_FUNCTION(socket_recvfrom)
16071608

16081609
if (arg6 == NULL) {
16091610
zend_string_efree(recv_buf);
1610-
WRONG_PARAM_COUNT;
1611+
zend_argument_value_error(6, "must be specified when argument #1 ($socket) is of type AF_INET or AF_INET6");
1612+
RETURN_THROWS();
16111613
}
16121614

16131615
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, (socklen_t *)&slen);

ext/sockets/tests/socket_recvfrom_ipv4_missing_port_arg.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414

1515
?>
1616
--EXPECT--
17-
ArgumentCountError: Wrong parameter count for socket_recvfrom()
17+
ValueError: socket_recvfrom(): Argument #6 ($port) must be specified when argument #1 ($socket) is of type AF_INET or AF_INET6

ext/sockets/tests/socket_recvfrom_ipv6_missing_port_arg.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414

1515
?>
1616
--EXPECT--
17-
ArgumentCountError: Wrong parameter count for socket_recvfrom()
17+
ValueError: socket_recvfrom(): Argument #6 ($port) must be specified when argument #1 ($socket) is of type AF_INET or AF_INET6

0 commit comments

Comments
 (0)