You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/02/15 11:38:11 UTC

[incubator-nuttx-apps] branch master updated: Fix error: 'strncpy' specified bound 16 equals destination size

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 0426c8c  Fix error: 'strncpy' specified bound 16 equals destination size
0426c8c is described below

commit 0426c8c09fdbed92cc0fc799d990bad9905822a8
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Feb 13 14:46:40 2022 +0800

    Fix error: 'strncpy' specified bound 16 equals destination size
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 netutils/netlib/netlib_autoconfig.c     | 2 +-
 netutils/netlib/netlib_getdripv4addr.c  | 2 +-
 netutils/netlib/netlib_getessid.c       | 2 +-
 netutils/netlib/netlib_getifstatus.c    | 2 +-
 netutils/netlib/netlib_getipv4addr.c    | 2 +-
 netutils/netlib/netlib_getipv4netmask.c | 2 +-
 netutils/netlib/netlib_getipv6addr.c    | 2 +-
 netutils/netlib/netlib_getmacaddr.c     | 2 +-
 netutils/netlib/netlib_setdripv4addr.c  | 2 +-
 netutils/netlib/netlib_setdripv6addr.c  | 2 +-
 netutils/netlib/netlib_setessid.c       | 2 +-
 netutils/netlib/netlib_setifstatus.c    | 4 ++--
 netutils/netlib/netlib_setipv4addr.c    | 2 +-
 netutils/netlib/netlib_setipv4netmask.c | 2 +-
 netutils/netlib/netlib_setipv6addr.c    | 2 +-
 netutils/netlib/netlib_setipv6netmask.c | 2 +-
 netutils/netlib/netlib_setmacaddr.c     | 2 +-
 17 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/netutils/netlib/netlib_autoconfig.c b/netutils/netlib/netlib_autoconfig.c
index d094a82..56f169d 100644
--- a/netutils/netlib/netlib_autoconfig.c
+++ b/netutils/netlib/netlib_autoconfig.c
@@ -71,7 +71,7 @@ int netlib_icmpv6_autoconfiguration(FAR const char *ifname)
           /* Create a request consisting only of the interface name */
 
           struct lifreq req;
-          strncpy(req.lifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.lifr_name, ifname, IFNAMSIZ);
 
           /* Perform the ICMPv6 auto-configuration and close the socket */
 
diff --git a/netutils/netlib/netlib_getdripv4addr.c b/netutils/netlib/netlib_getdripv4addr.c
index efafd6c..32398ba 100644
--- a/netutils/netlib/netlib_getdripv4addr.c
+++ b/netutils/netlib/netlib_getdripv4addr.c
@@ -70,7 +70,7 @@ int netlib_get_dripv4addr(FAR const char *ifname, FAR struct in_addr *addr)
       if (sockfd >= 0)
         {
           struct ifreq req;
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
           ret = ioctl(sockfd, SIOCGIFDSTADDR, (unsigned long)&req);
           if (!ret)
             {
diff --git a/netutils/netlib/netlib_getessid.c b/netutils/netlib/netlib_getessid.c
index baa59d3..6204c17 100644
--- a/netutils/netlib/netlib_getessid.c
+++ b/netutils/netlib/netlib_getessid.c
@@ -77,7 +77,7 @@ int netlib_getessid(FAR const char *ifname, FAR char *essid, size_t idlen)
           /* Put the driver name into the request */
 
           memset(&req, 0, sizeof(struct iwreq));
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Put pointer to receive the ESSID into the request */
 
diff --git a/netutils/netlib/netlib_getifstatus.c b/netutils/netlib/netlib_getifstatus.c
index e4688af..0105a16 100644
--- a/netutils/netlib/netlib_getifstatus.c
+++ b/netutils/netlib/netlib_getifstatus.c
@@ -73,7 +73,7 @@ int netlib_getifstatus(FAR const char *ifname, FAR uint8_t *flags)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Perform the ioctl to ifup or ifdown status */
 
diff --git a/netutils/netlib/netlib_getipv4addr.c b/netutils/netlib/netlib_getipv4addr.c
index 3253808..56a6185 100644
--- a/netutils/netlib/netlib_getipv4addr.c
+++ b/netutils/netlib/netlib_getipv4addr.c
@@ -70,7 +70,7 @@ int netlib_get_ipv4addr(FAR const char *ifname, FAR struct in_addr *addr)
       if (sockfd >= 0)
         {
           struct ifreq req;
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
           ret = ioctl(sockfd, SIOCGIFADDR, (unsigned long)&req);
           if (!ret)
             {
diff --git a/netutils/netlib/netlib_getipv4netmask.c b/netutils/netlib/netlib_getipv4netmask.c
index 3c8e66e..a341774 100644
--- a/netutils/netlib/netlib_getipv4netmask.c
+++ b/netutils/netlib/netlib_getipv4netmask.c
@@ -70,7 +70,7 @@ int netlib_get_ipv4netmask(FAR const char *ifname, FAR struct in_addr *addr)
       if (sockfd >= 0)
         {
           struct ifreq req;
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
           ret = ioctl(sockfd, SIOCGIFNETMASK, (unsigned long)&req);
           if (!ret)
             {
diff --git a/netutils/netlib/netlib_getipv6addr.c b/netutils/netlib/netlib_getipv6addr.c
index 8c38e99..1260e1f 100644
--- a/netutils/netlib/netlib_getipv6addr.c
+++ b/netutils/netlib/netlib_getipv6addr.c
@@ -71,7 +71,7 @@ int netlib_get_ipv6addr(FAR const char *ifname, FAR struct in6_addr *addr)
         {
           struct lifreq req;
 
-          strncpy(req.lifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.lifr_name, ifname, IFNAMSIZ);
           ret = ioctl(sockfd, SIOCGLIFADDR, (unsigned long)&req);
           if (!ret)
             {
diff --git a/netutils/netlib/netlib_getmacaddr.c b/netutils/netlib/netlib_getmacaddr.c
index 387aa7c..46b799b 100644
--- a/netutils/netlib/netlib_getmacaddr.c
+++ b/netutils/netlib/netlib_getmacaddr.c
@@ -72,7 +72,7 @@ int netlib_getmacaddr(const char *ifname, uint8_t *macaddr)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Perform the ioctl to get the MAC address */
 
diff --git a/netutils/netlib/netlib_setdripv4addr.c b/netutils/netlib/netlib_setdripv4addr.c
index c1e37d5..f04dba4 100644
--- a/netutils/netlib/netlib_setdripv4addr.c
+++ b/netutils/netlib/netlib_setdripv4addr.c
@@ -90,7 +90,7 @@ int netlib_set_dripv4addr(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setdripv6addr.c b/netutils/netlib/netlib_setdripv6addr.c
index 947b1ff..4da663e 100644
--- a/netutils/netlib/netlib_setdripv6addr.c
+++ b/netutils/netlib/netlib_setdripv6addr.c
@@ -71,7 +71,7 @@ int netlib_set_dripv6addr(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.lifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.lifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setessid.c b/netutils/netlib/netlib_setessid.c
index 8f49d37..ab91d09 100644
--- a/netutils/netlib/netlib_setessid.c
+++ b/netutils/netlib/netlib_setessid.c
@@ -75,7 +75,7 @@ int netlib_setessid(FAR const char *ifname, FAR const char *essid)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Put the new ESSID into the request */
 
diff --git a/netutils/netlib/netlib_setifstatus.c b/netutils/netlib/netlib_setifstatus.c
index 57e49f6..8ed30fa 100644
--- a/netutils/netlib/netlib_setifstatus.c
+++ b/netutils/netlib/netlib_setifstatus.c
@@ -71,7 +71,7 @@ int netlib_ifup(const char *ifname)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Perform the ioctl to ifup flag */
 
@@ -114,7 +114,7 @@ int netlib_ifdown(const char *ifname)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Perform the ioctl to ifup flag */
 
diff --git a/netutils/netlib/netlib_setipv4addr.c b/netutils/netlib/netlib_setipv4addr.c
index d2b2db6..dca8f09 100644
--- a/netutils/netlib/netlib_setipv4addr.c
+++ b/netutils/netlib/netlib_setipv4addr.c
@@ -71,7 +71,7 @@ int netlib_set_ipv4addr(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setipv4netmask.c b/netutils/netlib/netlib_setipv4netmask.c
index dca7c3b..c34b017 100644
--- a/netutils/netlib/netlib_setipv4netmask.c
+++ b/netutils/netlib/netlib_setipv4netmask.c
@@ -70,7 +70,7 @@ int netlib_set_ipv4netmask(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setipv6addr.c b/netutils/netlib/netlib_setipv6addr.c
index 956303d..79cad9b 100644
--- a/netutils/netlib/netlib_setipv6addr.c
+++ b/netutils/netlib/netlib_setipv6addr.c
@@ -71,7 +71,7 @@ int netlib_set_ipv6addr(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.lifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.lifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setipv6netmask.c b/netutils/netlib/netlib_setipv6netmask.c
index ab60412..985d55e 100644
--- a/netutils/netlib/netlib_setipv6netmask.c
+++ b/netutils/netlib/netlib_setipv6netmask.c
@@ -70,7 +70,7 @@ int netlib_set_ipv6netmask(FAR const char *ifname,
 
           /* Add the device name to the request */
 
-          strncpy(req.lifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.lifr_name, ifname, IFNAMSIZ);
 
           /* Add the INET address to the request */
 
diff --git a/netutils/netlib/netlib_setmacaddr.c b/netutils/netlib/netlib_setmacaddr.c
index 55aed87..07c3263 100644
--- a/netutils/netlib/netlib_setmacaddr.c
+++ b/netutils/netlib/netlib_setmacaddr.c
@@ -72,7 +72,7 @@ int netlib_setmacaddr(const char *ifname, const uint8_t *macaddr)
 
           /* Put the driver name into the request */
 
-          strncpy(req.ifr_name, ifname, IFNAMSIZ);
+          strlcpy(req.ifr_name, ifname, IFNAMSIZ);
 
           /* Put the new MAC address into the request */