Date: Sat, 3 Feb 2024 04:08:04 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: af87ba65223f - main - traceroute: Silence compiler warning Message-ID: <202402030408.413484DZ065403@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=af87ba65223f05e14590a2564e8c7b4eec7b53a7 commit af87ba65223f05e14590a2564e8c7b4eec7b53a7 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2023-11-17 16:15:27 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-03 03:14:09 +0000 traceroute: Silence compiler warning Silence the warning: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination?" by using strlcpy() and the size of the destination (device). No functional change intended. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/901 --- contrib/traceroute/ifaddrlist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/traceroute/ifaddrlist.c b/contrib/traceroute/ifaddrlist.c index f9a72b28d4a7..0523a47ce61d 100644 --- a/contrib/traceroute/ifaddrlist.c +++ b/contrib/traceroute/ifaddrlist.c @@ -141,8 +141,7 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf) continue; - (void)strncpy(device, ifr.ifr_name, sizeof(ifr.ifr_name)); - device[sizeof(device) - 1] = '\0'; + (void)strlcpy(device, ifr.ifr_name, sizeof(device)); #ifdef sun /* Ignore sun virtual interfaces */ if (strchr(device, ':') != NULL)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402030408.413484DZ065403>