netutils/netlib: Fix 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-05 01:49:01 +08:00
committed by Petro Karashchenko
parent f31cc67da8
commit 3afd1234e0
7 changed files with 8 additions and 8 deletions

View File

@@ -230,8 +230,8 @@ ssize_t netlib_get_devices(FAR struct netlib_device_s *devlist,
devlist[ncopied].ifindex = iface->ifi_index;
#endif
strncpy(devlist[ncopied].ifname,
(FAR char *)RTA_DATA(attr), IFNAMSIZ);
strlcpy(devlist[ncopied].ifname,
(FAR char *)RTA_DATA(attr), IFNAMSIZ);
ncopied++;
}

View File

@@ -72,7 +72,7 @@ int netlib_getnodnodeaddr(FAR const char *ifname,
{
/* Copy the network interface name */
strncpy(req.pifr_name, ifname, IFNAMSIZ);
strlcpy(req.pifr_name, ifname, IFNAMSIZ);
/* And perform the IOCTL command */

View File

@@ -72,7 +72,7 @@ int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid)
{
/* Perform the IOCTL */
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_PANID;
ret = ioctl(sockfd, MAC802154IOC_MLME_GET_REQUEST,

View File

@@ -72,7 +72,7 @@ int netlib_getproperties(FAR const char *ifname,
{
/* Copy the network interface name */
strncpy(req.pifr_name, ifname, IFNAMSIZ);
strlcpy(req.pifr_name, ifname, IFNAMSIZ);
/* And perform the IOCTL command */

View File

@@ -165,7 +165,7 @@ static int _netlib_ipv6adaptor(FAR const struct in6_addr *destipaddr,
/* Get the network mask */
strncpy(maskreq.lifr_name, lifr->lifr_name, IFNAMSIZ);
strlcpy(maskreq.lifr_name, lifr->lifr_name, IFNAMSIZ);
status = ioctl(sd, SIOCGLIFNETMASK,
(unsigned long)((uintptr_t)&maskreq));

View File

@@ -72,7 +72,7 @@ int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr)
{
/* Perform the IOCTL */
strncpy(arg.ifr_name, ifname, IFNAMSIZ);
strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.setreq.attr = IEEE802154_ATTR_MAC_EADDR;
IEEE802154_EADDRCOPY(arg.u.setreq.attrval.mac.eaddr, eaddr);

View File

@@ -72,7 +72,7 @@ int netlib_setnodeaddr(FAR const char *ifname,
{
/* Copy the network interface name */
strncpy(req.pifr_name, ifname, IFNAMSIZ);
strlcpy(req.pifr_name, ifname, IFNAMSIZ);
/* Copy the node address into the request */