From 8f16b02b2495bfd3245820493a8ec18960f11995 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 24 Jul 2025 18:03:37 +0200 Subject: [PATCH] fix tun_if.c warning: specified bound 16 equals destination size --- common/utils/tun_if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/utils/tun_if.c b/common/utils/tun_if.c index 4bb1f7ec58..f74ab3c7f2 100644 --- a/common/utils/tun_if.c +++ b/common/utils/tun_if.c @@ -120,7 +120,7 @@ static bool setInterfaceParameter(int sock_fd, const char *ifn, int af, const ch { DevAssert(af == AF_INET || af == AF_INET6); struct ifreq ifr = {0}; - strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name) - 1); struct in6_ifreq ifr6 = {0}; void *ioctl_opt = NULL; @@ -167,7 +167,7 @@ static bool change_interface_state(int sock_fd, const char *ifn, if_action_t if_ const char *action = if_action == INTERFACE_DOWN ? "DOWN" : "UP"; struct ifreq ifr = {0}; - strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, ifn, sizeof(ifr.ifr_name) - 1); /* get flags of this interface: see netdevice(7) */ bool success = ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t)&ifr) == 0;