From: Reuben Dowle Date: Thu, 4 Mar 2021 01:03:07 +0000 (+1300) Subject: nhrpd: Use strlcpy not unsafe strncpy X-Git-Tag: base_8.0~145^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ca317495b8aa18bfacf8b9ac83479cf14d8651db;p=matthieu%2Ffrr.git nhrpd: Use strlcpy not unsafe strncpy Signed-off-by: Reuben Dowle --- diff --git a/nhrpd/linux.c b/nhrpd/linux.c index 20825149b8..e729f72644 100644 --- a/nhrpd/linux.c +++ b/nhrpd/linux.c @@ -32,6 +32,11 @@ #include "os.h" #include "netlink.h" +#ifndef HAVE_STRLCPY +size_t strlcpy(char *__restrict dest, + const char *__restrict src, size_t destsize); +#endif + static int nhrp_socket_fd = -1; int os_socket(void) @@ -112,7 +117,7 @@ static int linux_configure_arp(const char *iface, int on) { struct ifreq ifr; - strncpy(ifr.ifr_name, iface, IFNAMSIZ - 1); + strlcpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(nhrp_socket_fd, SIOCGIFFLAGS, &ifr)) return -1;