From 179c85aa06d670ca48844a2e0d009fb3863a424e Mon Sep 17 00:00:00 2001 From: Axel Le Bourhis Date: Fri, 23 Aug 2024 12:43:46 +0200 Subject: [PATCH] tests: net: socket: udp: clear control data buffer before recvmsg Currently, the test doesn't clear the control data buffer before calling recvmsg. This leads to recvmsg being unable to add the new control data, which corresponds to the current received data. This commit aims to clear the control data buffer to match most use cases, when the control data buffer is empty before calling recvmsg. Signed-off-by: Axel Le Bourhis --- tests/net/socket/udp/src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/net/socket/udp/src/main.c b/tests/net/socket/udp/src/main.c index bf48207e862253..5874ed9f6e4d9a 100644 --- a/tests/net/socket/udp/src/main.c +++ b/tests/net/socket/udp/src/main.c @@ -1492,6 +1492,7 @@ static void comm_sendmsg_recvmsg(int client_sock, io_vector[0].iov_len = sizeof(buf); memset(msg, 0, sizeof(*msg)); + memset(cmsgbuf, 0, cmsgbuf_len); msg->msg_control = cmsgbuf; msg->msg_controllen = cmsgbuf_len; msg->msg_iov = io_vector; @@ -1565,6 +1566,7 @@ static void comm_sendmsg_recvmsg(int client_sock, io_vector[1].iov_len = sizeof(buf); memset(msg, 0, sizeof(*msg)); + memset(cmsgbuf, 0, cmsgbuf_len); msg->msg_control = cmsgbuf; msg->msg_controllen = cmsgbuf_len; msg->msg_iov = io_vector; @@ -1624,6 +1626,7 @@ static void comm_sendmsg_recvmsg(int client_sock, io_vector[0].iov_len = sizeof(buf2); memset(msg, 0, sizeof(*msg)); + memset(cmsgbuf, 0, cmsgbuf_len); msg->msg_control = cmsgbuf; msg->msg_controllen = cmsgbuf_len; msg->msg_iov = io_vector;