udp_peek_addr() initialises struct msghdr without setting msg_iov,
leaving it implicitly NULL. Coverity flags this as FORWARD_NULL,
believing recvmsg() will dereference the NULL pointer.
In practice, msg_iovlen being zero means the kernel never touches
msg_iov, so the warning is a false positive. We now provide a
one-byte dummy iov to make msg_iov non-NULL, hence suppressing this
warning without changing the function's behaviour.
Signed-off-by: Jon Maloy
---
udp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/udp.c b/udp.c
index c28d6ee2..f648cb8b 100644
--- a/udp.c
+++ b/udp.c
@@ -734,9 +734,16 @@ static int udp_peek_addr(int s, union sockaddr_inany *src,
{
char sastr[SOCKADDR_STRLEN], dstr[INANY_ADDRSTRLEN];
char cmsg[PKTINFO_SPACE];
+ char dummy;
+ struct iovec iov = {
+ .iov_base = &dummy,
+ .iov_len = sizeof(dummy),
+ };
struct msghdr msg = {
.msg_name = src,
.msg_namelen = sizeof(*src),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
.msg_control = cmsg,
.msg_controllen = sizeof(cmsg),
};
--
2.52.0