From 59e47e9b9a12d692ecf31d2a68407b42ae78dfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20J=2E=20Saraiva?= Date: Fri, 15 Mar 2024 16:06:19 +0000 Subject: [PATCH] Clarify why IPV6_V6ONLY is being unset. Try to silence the coverity defect with a (void) cast. --- common/net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/net.c b/common/net.c index 470499ce7..1761bdee9 100644 --- a/common/net.c +++ b/common/net.c @@ -547,7 +547,10 @@ static int ip_socket_bind(struct addrinfo *addr) return(-1); #ifdef IPV6_V6ONLY - setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&off,sizeof(off)); + if (addr->ai_family == AF_INET6) { + // if supported, allow packets to/from IPv4-mapped IPv6 addresses + (void)setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&off,sizeof(off)); + } #endif if ( (bind(fd,addr->ai_addr,addr->ai_addrlen) < 0) ||