Fix net/lib_nametoindex.c:58:7: error: 'strncpy' specified bound 16 equals destination size

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-02 23:30:47 +08:00 committed by Petro Karashchenko
parent 8267a76186
commit be2f688cd9
1 changed files with 1 additions and 1 deletions

View File

@ -55,7 +55,7 @@ unsigned int if_nametoindex(FAR const char *ifname)
if (sockfd >= 0) if (sockfd >= 0)
{ {
struct ifreq req; struct ifreq req;
strncpy(req.ifr_name, ifname, IF_NAMESIZE); strlcpy(req.ifr_name, ifname, IF_NAMESIZE);
if (ioctl(sockfd, SIOCGIFINDEX, (unsigned long)&req) >= 0) if (ioctl(sockfd, SIOCGIFINDEX, (unsigned long)&req) >= 0)
{ {
close(sockfd); close(sockfd);