net: socket: Incorrect msg_iovlen
value with TCP Sockets in zsock_recvmsg()
#84475
Labels
msg_iovlen
value with TCP Sockets in zsock_recvmsg()
#84475
Describe the bug
The function
ssize_t zsock_recvmsg(int sock, struct msghdr *msg, int flags)
is expected to receive data and store it into buffers specified by themsg->msg_iov
array. Themsg->msg_iovlen
field indicates the number of buffers in the array. However, when using a TCP socket, themsg->msg_iovlen
value is incorrectly updated after a successful receive operation, reducing its value unexpectedly. This issue does not occur with UDP sockets.To Reproduce
msg_iov
:msg->msg_iovlen
= 2.zsock_recvmsg()
on the client to receive the message.msg->msg_iovlen
valueExpected behavior
msg->msg_iovlen
remains unchanged at 2 as two buffers were used for storing the dataImpact
This bug causes confusion and potential misinterpretation of the
msg->msg_iovlen
value, particularly in cases where applications rely on it to verify the number of buffers used for data storage.Environment (please complete the following information):
Additional context
The
msg_iovlen
is modified in functionzsock_recv_stream_timed()
in modulesubsys/net/lib/sockets/sockets_inet.c
.The code:
should be probably moved after
msg->msg_iovlen = iovec;
in order to fix this issue.The text was updated successfully, but these errors were encountered: