Skip to content

Commit d7ba097

Browse files
jukkarnashif
authored andcommitted
net: socket: Return 0 in recvfrom() if buffer size is 0
If user has buffer with size 0, then return 0. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 3159e9f commit d7ba097

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/net/lib/sockets/sockets.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,10 @@ ssize_t zsock_recvfrom_ctx(struct net_context *ctx, void *buf, size_t max_len,
802802
{
803803
enum net_sock_type sock_type = net_context_get_type(ctx);
804804

805+
if (max_len == 0) {
806+
return 0;
807+
}
808+
805809
if (sock_type == SOCK_DGRAM) {
806810
return zsock_recv_dgram(ctx, buf, max_len, flags, src_addr, addrlen);
807811
} else if (sock_type == SOCK_STREAM) {

0 commit comments

Comments
 (0)