This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 3afd123  netutils/netlib: Fix error: 'strncpy' specified bound 16 
equals destination size
3afd123 is described below

commit 3afd1234e0de827c944c60c52b14843bf547bce8
Author: Xiang Xiao <[email protected]>
AuthorDate: Sat Mar 5 01:49:01 2022 +0800

    netutils/netlib: Fix error: 'strncpy' specified bound 16 equals destination 
size
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 netutils/netlib/netlib_getdevs.c       | 4 ++--
 netutils/netlib/netlib_getnodeaddr.c   | 2 +-
 netutils/netlib/netlib_getpanid.c      | 2 +-
 netutils/netlib/netlib_getproperties.c | 2 +-
 netutils/netlib/netlib_ipv6adaptor.c   | 2 +-
 netutils/netlib/netlib_seteaddr.c      | 2 +-
 netutils/netlib/netlib_setnodeaddr.c   | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/netutils/netlib/netlib_getdevs.c b/netutils/netlib/netlib_getdevs.c
index fba96e7..4a02485 100644
--- a/netutils/netlib/netlib_getdevs.c
+++ b/netutils/netlib/netlib_getdevs.c
@@ -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++;
                           }
 
diff --git a/netutils/netlib/netlib_getnodeaddr.c 
b/netutils/netlib/netlib_getnodeaddr.c
index 2367238..1972445 100644
--- a/netutils/netlib/netlib_getnodeaddr.c
+++ b/netutils/netlib/netlib_getnodeaddr.c
@@ -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 */
 
diff --git a/netutils/netlib/netlib_getpanid.c 
b/netutils/netlib/netlib_getpanid.c
index 0692adc..ca63db1 100644
--- a/netutils/netlib/netlib_getpanid.c
+++ b/netutils/netlib/netlib_getpanid.c
@@ -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,
diff --git a/netutils/netlib/netlib_getproperties.c 
b/netutils/netlib/netlib_getproperties.c
index 0908bde..d0f2c4c 100644
--- a/netutils/netlib/netlib_getproperties.c
+++ b/netutils/netlib/netlib_getproperties.c
@@ -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 */
 
diff --git a/netutils/netlib/netlib_ipv6adaptor.c 
b/netutils/netlib/netlib_ipv6adaptor.c
index 330bde1..1afa6cd 100644
--- a/netutils/netlib/netlib_ipv6adaptor.c
+++ b/netutils/netlib/netlib_ipv6adaptor.c
@@ -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));
diff --git a/netutils/netlib/netlib_seteaddr.c 
b/netutils/netlib/netlib_seteaddr.c
index ba359b3..6008fc3 100644
--- a/netutils/netlib/netlib_seteaddr.c
+++ b/netutils/netlib/netlib_seteaddr.c
@@ -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);
 
diff --git a/netutils/netlib/netlib_setnodeaddr.c 
b/netutils/netlib/netlib_setnodeaddr.c
index bf22d67..7e41e59 100644
--- a/netutils/netlib/netlib_setnodeaddr.c
+++ b/netutils/netlib/netlib_setnodeaddr.c
@@ -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 */
 

Reply via email to