public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] udp: Provide dummy iov in udp_peek_addr() to avoid Coverity warning
@ 2026-05-31 20:20 Jon Maloy
  2026-06-02  1:55 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Maloy @ 2026-05-31 20:20 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

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 <jmaloy@redhat.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-02  1:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-31 20:20 [PATCH] udp: Provide dummy iov in udp_peek_addr() to avoid Coverity warning Jon Maloy
2026-06-02  1:55 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).