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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8ad4ae550 net: fix compiler warning
8ad4ae550 is described below

commit 8ad4ae5508eb2e2c724477fb7fba1d13322abf0c
Author: chao an <[email protected]>
AuthorDate: Tue Feb 7 19:33:52 2023 +0800

    net: fix compiler warning
    
    sixlowpan_assocresp.c: In function ‘sixlowpan_assoc_resp’:
    sixlowpan_assocresp.c:48:3: warning: ‘strncpy’ specified bound 16 equals 
destination size [-Wstringop-truncation]
       48 |   strncpy(arg.ifr_name, ifname, IFNAMSIZ);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: chao an <[email protected]>
---
 canutils/cansend/cansend.c                         | 266 +++++++++++++--------
 canutils/slcan/slcan.c                             |   3 +-
 examples/canardv1/socketcan.c                      |   3 +-
 netutils/discover/discover.c                       |   2 +-
 netutils/netinit/netinit.c                         |   2 +-
 netutils/netlib/netlib_ipv4adaptor.c               |   2 +-
 netutils/pppd/pppd.c                               |   2 +-
 system/mdio/mdio_main.c                            |   6 +-
 wireless/bluetooth/btsak/btsak_advertise.c         |   4 +-
 wireless/bluetooth/btsak/btsak_features.c          |   2 +-
 wireless/bluetooth/btsak/btsak_gatt.c              |  10 +-
 wireless/bluetooth/btsak/btsak_info.c              |   2 +-
 wireless/bluetooth/btsak/btsak_scan.c              |   6 +-
 wireless/bluetooth/btsak/btsak_security.c          |   2 +-
 wireless/ieee802154/i8sak/i8sak_events.c           |   4 +-
 wireless/ieee802154/libmac/sixlowpan_assocreq.c    |   2 +-
 wireless/ieee802154/libmac/sixlowpan_assocresp.c   |   2 +-
 wireless/ieee802154/libmac/sixlowpan_disassocreq.c |   2 +-
 wireless/ieee802154/libmac/sixlowpan_getreq.c      |   2 +-
 wireless/ieee802154/libmac/sixlowpan_gtsreq.c      |   2 +-
 wireless/ieee802154/libmac/sixlowpan_orphanresp.c  |   2 +-
 wireless/ieee802154/libmac/sixlowpan_pollreq.c     |   2 +-
 wireless/ieee802154/libmac/sixlowpan_resetreq.c    |   2 +-
 wireless/ieee802154/libmac/sixlowpan_rxenabreq.c   |   2 +-
 wireless/ieee802154/libmac/sixlowpan_scanreq.c     |   2 +-
 wireless/ieee802154/libmac/sixlowpan_setreq.c      |   2 +-
 wireless/ieee802154/libmac/sixlowpan_startreq.c    |   2 +-
 wireless/ieee802154/libmac/sixlowpan_syncreq.c     |   2 +-
 28 files changed, 197 insertions(+), 145 deletions(-)

diff --git a/canutils/cansend/cansend.c b/canutils/cansend/cansend.c
index 1001b52c8..ade275066 100644
--- a/canutils/cansend/cansend.c
+++ b/canutils/cansend/cansend.c
@@ -1,5 +1,26 @@
-/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
-/*
+/****************************************************************************
+ * apps/canutils/cansend/cansend.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) *
+ *
  * cansend.c - send CAN-frames via CAN_RAW sockets
  *
  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
@@ -40,7 +61,11 @@
  *
  * Send feedback to <[email protected]>
  *
- */
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -58,112 +83,141 @@
 
 static void print_usage_send(char *prg)
 {
-       fprintf(stderr, "%s - send CAN-frames via CAN_RAW sockets.\n", prg);
-       fprintf(stderr, "\nUsage: %s <device> <can_frame>.\n", prg);
-       fprintf(stderr, "\n<can_frame>:\n");
-       fprintf(stderr, " <can_id>#{data}          for 'classic' CAN 2.0 data 
frames\n");
-       fprintf(stderr, " <can_id>#R{len}          for 'classic' CAN 2.0 data 
frames\n");
-       fprintf(stderr, " <can_id>##<flags>{data}  for CAN FD frames\n\n");
-       fprintf(stderr, "<can_id>:\n"
-               " 3 (SFF) or 8 (EFF) hex chars\n");
-       fprintf(stderr, "{data}:\n"
-               " 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by 
'.')\n");
-       fprintf(stderr, "{len}:\n"
-                " an optional 0..8 value as RTR frames can contain a valid dlc 
field\n");
-       fprintf(stderr, "<flags>:\n"
-               " a single ASCII Hex value (0 .. F) which defines 
canfd_frame.flags\n\n");
-       fprintf(stderr, "Examples:\n");
-       fprintf(stderr, "  5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 
123##1 / 213##311223344 /\n"
-                "  1F334455#1122334455667788 / 123#R / 00000123#R3\n\n");
+  fprintf(stderr, "%s - send CAN-frames via CAN_RAW sockets.\n", prg);
+  fprintf(stderr, "\nUsage: %s <device> <can_frame>.\n", prg);
+  fprintf(stderr, "\n<can_frame>:\n");
+  fprintf(stderr,
+          " <can_id>#{data}          ""for 'classic' CAN 2.0 data frames\n");
+  fprintf(stderr,
+          " <can_id>#R{len}          for 'classic' CAN 2.0 data frames\n");
+  fprintf(stderr,
+          " <can_id>##<flags>{data}  for CAN FD frames\n\n");
+  fprintf(stderr, "<can_id>:\n"
+          " 3 (SFF) or 8 (EFF) hex chars\n");
+  fprintf(stderr, "{data}:\n"
+          " 0..8 (0..64 CAN FD) ASCII hex-values "
+          "(optionally separated by '.')\n");
+  fprintf(stderr, "{len}:\n"
+          " an optional 0..8 value "
+          "as RTR frames can contain a valid dlc field\n");
+  fprintf(stderr, "<flags>:\n"
+          " a single ASCII Hex value (0 .. F) "
+          "which defines canfd_frame.flags\n\n");
+  fprintf(stderr, "Examples:\n");
+  fprintf(stderr, "  5A1#11.2233.44556677.88 / 123#DEADBEEF / "
+                  "5AA# / 123##1 / 213##311223344 /\n"
+                  "  1F334455#1122334455667788 / 123#R / 00000123#R3\n\n");
 }
 
-
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 int main(int argc, char **argv)
 {
-       int s; /* can raw socket */
-       int required_mtu;
-       int mtu;
-       int enable_canfd = 1;
-       struct sockaddr_can addr;
-       struct canfd_frame frame;
-       struct ifreq ifr;
-
-       /* check command line options */
-       if (argc != 3) {
-               print_usage_send(argv[0]);
-               return 1;
-       }
-
-       /* parse CAN frame */
-       required_mtu = parse_canframe(argv[2], &frame);
-       if (!required_mtu){
-               fprintf(stderr, "\nWrong CAN-frame format!\n\n");
-               print_usage_send(argv[0]);
-               return 1;
-       }
-
-       /* open socket */
-       if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-               perror("socket");
-               return 1;
-       }
-
-       strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1);
-       ifr.ifr_name[IFNAMSIZ - 1] = '\0';
-       ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
-       if (!ifr.ifr_ifindex) {
-               perror("if_nametoindex");
-               return 1;
-       }
-
-       memset(&addr, 0, sizeof(addr));
-       addr.can_family = AF_CAN;
-       addr.can_ifindex = ifr.ifr_ifindex;
-
-       if (required_mtu > (int)CAN_MTU) {
-
-               /* check if the frame fits into the CAN netdevice */
-               if (ioctl(s, SIOCGIFMTU, &ifr) < 0) {
-                       perror("SIOCGIFMTU");
-                       return 1;
-               }
-               mtu = ifr.ifr_mtu;
-
-               if (mtu != CANFD_MTU) {
-                       printf("CAN interface is not CAN FD capable - 
sorry.\n");
-                       return 1;
-               }
-
-               /* interface is ok - try to switch the socket into CAN FD mode 
*/
-               if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FD_FRAMES,
-                              &enable_canfd, sizeof(enable_canfd))){
-                       printf("error when enabling CAN FD support\n");
-                       return 1;
-               }
-
-               /* ensure discrete CAN FD length values 0..8, 12, 16, 20, 24, 
32, 64 */
-               frame.len = can_dlc2len(can_len2dlc(frame.len));
-       }
-
-       /* disable default receive filter on this RAW socket */
-       /* This is obsolete as we do not read from the socket at all, but for */
-       /* this reason we can remove the receive list in the Kernel to save a */
-       /* little (really a very little!) CPU usage.                          */
-       setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
-
-       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-               perror("bind");
-               return 1;
-       }
-
-       /* send frame */
-       if (write(s, &frame, required_mtu) != required_mtu) {
-               perror("write");
-               return 1;
-       }
-
-       close(s);
-
-       return 0;
+  /* can raw socket */
+
+  int s;
+  int required_mtu;
+  int mtu;
+  int enable_canfd = 1;
+  struct sockaddr_can addr;
+  struct canfd_frame frame;
+  struct ifreq ifr;
+
+  /* check command line options */
+
+  if (argc != 3)
+    {
+      print_usage_send(argv[0]);
+      return 1;
+    }
+
+  /* parse CAN frame */
+
+  required_mtu = parse_canframe(argv[2], &frame);
+  if (!required_mtu)
+    {
+      fprintf(stderr, "\nWrong CAN-frame format!\n\n");
+      print_usage_send(argv[0]);
+      return 1;
+    }
+
+  /* open socket */
+
+  if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0)
+    {
+      perror("socket");
+      return 1;
+    }
+
+  strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
+  ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
+  if (!ifr.ifr_ifindex)
+    {
+      perror("if_nametoindex");
+      return 1;
+    }
+
+  memset(&addr, 0, sizeof(addr));
+  addr.can_family = AF_CAN;
+  addr.can_ifindex = ifr.ifr_ifindex;
+
+  if (required_mtu > (int)CAN_MTU)
+    {
+      /* check if the frame fits into the CAN netdevice */
+
+      if (ioctl(s, SIOCGIFMTU, &ifr) < 0)
+        {
+          perror("SIOCGIFMTU");
+          return 1;
+        }
+
+      mtu = ifr.ifr_mtu;
+
+      if (mtu != CANFD_MTU)
+        {
+          printf("CAN interface is not CAN FD capable - sorry.\n");
+          return 1;
+        }
+
+      /* interface is ok - try to switch the socket into CAN FD mode */
+
+      if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FD_FRAMES,
+                     &enable_canfd, sizeof(enable_canfd)))
+        {
+          printf("error when enabling CAN FD support\n");
+          return 1;
+        }
+
+      /* ensure discrete CAN FD length values 0..8, 12, 16, 20, 24, 32, 64 */
+
+      frame.len = can_dlc2len(can_len2dlc(frame.len));
+    }
+
+  /* disable default receive filter on this RAW socket
+   * This is obsolete as we do not read from the socket at all, but for
+   * this reason we can remove the receive list in the Kernel to save a
+   * little (really a very little!) CPU usage.
+   */
+
+  setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
+
+  if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+    {
+      perror("bind");
+      return 1;
+    }
+
+  /* send frame */
+
+  if (write(s, &frame, required_mtu) != required_mtu)
+    {
+      perror("write");
+      return 1;
+    }
+
+  close(s);
+
+  return 0;
 }
diff --git a/canutils/slcan/slcan.c b/canutils/slcan/slcan.c
index dbe8cf54b..650b0406c 100644
--- a/canutils/slcan/slcan.c
+++ b/canutils/slcan/slcan.c
@@ -361,8 +361,7 @@ int main(int argc, char *argv[])
 
                           /* set the device name */
 
-                          strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1);
-                          ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+                          strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
 
                           ifr.ifr_ifru.ifru_can_data.arbi_bitrate =
                             canspeed / 1000; /* Convert bit/s to kbit/s */
diff --git a/examples/canardv1/socketcan.c b/examples/canardv1/socketcan.c
index 678724c46..9d4fd595b 100644
--- a/examples/canardv1/socketcan.c
+++ b/examples/canardv1/socketcan.c
@@ -49,8 +49,7 @@ int16_t socketcanopen(canardsocketinstance *ins,
       return -1;
     }
 
-  strncpy(ifr.ifr_name, can_iface_name, IFNAMSIZ - 1);
-  ifr.ifr_name[IFNAMSIZ - 1] = '\0';
+  strlcpy(ifr.ifr_name, can_iface_name, IFNAMSIZ);
   ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
 
   if (!ifr.ifr_ifindex)
diff --git a/netutils/discover/discover.c b/netutils/discover/discover.c
index 44c8706cd..84ab04984 100644
--- a/netutils/discover/discover.c
+++ b/netutils/discover/discover.c
@@ -347,7 +347,7 @@ static inline int discover_openlistener(void)
 
   /* Get the IP address of the selected device */
 
-  strncpy(req.ifr_name, CONFIG_DISCOVER_INTERFACE, IFNAMSIZ);
+  strlcpy(req.ifr_name, CONFIG_DISCOVER_INTERFACE, IFNAMSIZ);
   ret = ioctl(sockfd, SIOCGIFADDR, (unsigned long)&req);
   if (ret < 0)
     {
diff --git a/netutils/netinit/netinit.c b/netutils/netinit/netinit.c
index 9cbeb77b3..9e9d0a004 100644
--- a/netutils/netinit/netinit.c
+++ b/netutils/netinit/netinit.c
@@ -786,7 +786,7 @@ static int netinit_monitor(void)
       /* Configure to receive a signal on changes in link status */
 
       memset(&ifr, 0, sizeof(struct ifreq));
-      strncpy(ifr.ifr_name, NET_DEVNAME, IFNAMSIZ);
+      strlcpy(ifr.ifr_name, NET_DEVNAME, IFNAMSIZ);
 
       ifr.ifr_mii_notify_event.sigev_notify = SIGEV_SIGNAL;
       ifr.ifr_mii_notify_event.sigev_signo  = CONFIG_NETINIT_SIGNO;
diff --git a/netutils/netlib/netlib_ipv4adaptor.c 
b/netutils/netlib/netlib_ipv4adaptor.c
index b4b765a86..c38bd0df1 100644
--- a/netutils/netlib/netlib_ipv4adaptor.c
+++ b/netutils/netlib/netlib_ipv4adaptor.c
@@ -165,7 +165,7 @@ static int _netlib_ipv4adaptor(in_addr_t destipaddr,
 
       /* Get the network mask */
 
-      strncpy(maskreq.ifr_name, ifr->ifr_name, IFNAMSIZ);
+      strlcpy(maskreq.ifr_name, ifr->ifr_name, IFNAMSIZ);
 
       ret = ioctl(sd, SIOCGIFNETMASK, (unsigned long)((uintptr_t)&maskreq));
       if (ret < 0)
diff --git a/netutils/pppd/pppd.c b/netutils/pppd/pppd.c
index 819906f55..7ebeab348 100644
--- a/netutils/pppd/pppd.c
+++ b/netutils/pppd/pppd.c
@@ -123,7 +123,7 @@ static int tun_alloc(char *dev)
   ifr.ifr_flags = IFF_TUN;
   if (*dev)
     {
-      strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+      strlcpy(ifr.ifr_name, dev, IFNAMSIZ);
     }
 
   if ((errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr)) < 0)
diff --git a/system/mdio/mdio_main.c b/system/mdio/mdio_main.c
index b37eecdd3..2346a0502 100644
--- a/system/mdio/mdio_main.c
+++ b/system/mdio/mdio_main.c
@@ -83,7 +83,7 @@ int get_phy_id(void)
 
   /* Prepare ifreq */
 
-  strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
+  strlcpy(ifr.ifr_name, "eth0", IFNAMSIZ);
 
   ret = ioctl(g_listen_fd, SIOCGMIIPHY, (unsigned long) &ifr);
 
@@ -105,7 +105,7 @@ int get_phy_reg(uint16_t phy_id, uint16_t reg_num, uint16_t 
*val)
   int ret;
   struct ifreq ifr;
 
-  strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
+  strlcpy(ifr.ifr_name, "eth0", IFNAMSIZ);
 
   ifr.ifr_mii_phy_id = phy_id;
   ifr.ifr_mii_reg_num = reg_num;
@@ -125,7 +125,7 @@ int set_phy_reg(uint16_t phy_id, uint16_t reg_num, uint16_t 
val)
   int ret;
   struct ifreq ifr;
 
-  strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
+  strlcpy(ifr.ifr_name, "eth0", IFNAMSIZ);
 
   ifr.ifr_mii_phy_id = phy_id;
   ifr.ifr_mii_reg_num = reg_num;
diff --git a/wireless/bluetooth/btsak/btsak_advertise.c 
b/wireless/bluetooth/btsak/btsak_advertise.c
index 0982ad9b1..a2efb6b27 100644
--- a/wireless/bluetooth/btsak/btsak_advertise.c
+++ b/wireless/bluetooth/btsak/btsak_advertise.c
@@ -126,7 +126,7 @@ static void btsak_cmd_advertisestart(FAR struct btsak_s 
*btsak,
   strcpy((FAR char *)sd[1].data, "btsak");
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
   btreq.btr_advtype = BT_LE_ADV_IND;
   btreq.btr_advad   = ad;
   btreq.btr_advsd   = sd;
@@ -166,7 +166,7 @@ static void btsak_cmd_advertisestop(FAR struct btsak_s 
*btsak, FAR char *cmd,
   /* Perform the IOCTL to stop advertising */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
diff --git a/wireless/bluetooth/btsak/btsak_features.c 
b/wireless/bluetooth/btsak/btsak_features.c
index ceb408c72..5072d586c 100644
--- a/wireless/bluetooth/btsak/btsak_features.c
+++ b/wireless/bluetooth/btsak/btsak_features.c
@@ -105,7 +105,7 @@ void btsak_cmd_features(FAR struct btsak_s *btsak,
   /* Perform the IOCTL to stop advertising */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
diff --git a/wireless/bluetooth/btsak/btsak_gatt.c 
b/wireless/bluetooth/btsak/btsak_gatt.c
index c7485ace9..d306eae97 100644
--- a/wireless/bluetooth/btsak/btsak_gatt.c
+++ b/wireless/bluetooth/btsak/btsak_gatt.c
@@ -84,7 +84,7 @@ static void btsak_cmd_discover_common(FAR struct btsak_s 
*btsak,
       btsak_gatt_showusage(btsak->progname, argv[0], EXIT_FAILURE);
     }
 
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
   btreq.btr_dtype = (uint8_t)type;
 
   ret = btsak_str2addr(argv[1], btreq.btr_dpeer.val);
@@ -209,7 +209,7 @@ static void btsak_cmd_connect_common(FAR struct btsak_s 
*btsak, int argc,
 
   /* Perform the IOCTL to start/end the connection */
 
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
@@ -287,7 +287,7 @@ static void btsak_cmd_read_common(FAR struct btsak_s 
*btsak, int argc,
 
   /* Perform the IOCTL to start the read */
 
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
   btreq.btr_rdsize = HCI_GATTRD_DATA;
   btreq.btr_rddata = data;
 
@@ -372,7 +372,7 @@ void btsak_cmd_gatt_exchange_mtu(FAR struct btsak_s *btsak, 
int argc,
 
   /* Perform the IOCTL to start the MTU exchange */
 
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
@@ -546,7 +546,7 @@ void btsak_cmd_gatt_write(FAR struct btsak_s *btsak, int 
argc,
 
   /* Perform the IOCTL to start the read */
 
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
diff --git a/wireless/bluetooth/btsak/btsak_info.c 
b/wireless/bluetooth/btsak/btsak_info.c
index b177535db..1175506e5 100644
--- a/wireless/bluetooth/btsak/btsak_info.c
+++ b/wireless/bluetooth/btsak/btsak_info.c
@@ -91,7 +91,7 @@ void btsak_cmd_info(FAR struct btsak_s *btsak, int argc, FAR 
char *argv[])
   /* Perform the IOCTL to stop advertising */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
diff --git a/wireless/bluetooth/btsak/btsak_scan.c 
b/wireless/bluetooth/btsak/btsak_scan.c
index 5ab76e61f..2c8dfefc9 100644
--- a/wireless/bluetooth/btsak/btsak_scan.c
+++ b/wireless/bluetooth/btsak/btsak_scan.c
@@ -84,7 +84,7 @@ static void btsak_cmd_scanstart(FAR struct btsak_s *btsak, 
FAR char *cmd,
   int ret;
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   /* Check if an option was provided */
 
@@ -141,7 +141,7 @@ static void btsak_cmd_scanget(FAR struct btsak_s *btsak, 
FAR char *cmd,
   /* Perform the IOCTL to get the scan results so far */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
   btreq.btr_nrsp = 5;
   btreq.btr_rsp  = result;
 
@@ -219,7 +219,7 @@ static void btsak_cmd_scanstop(FAR struct btsak_s *btsak, 
FAR char *cmd,
   /* Perform the IOCTL to stop scanning and flush any buffered responses. */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
diff --git a/wireless/bluetooth/btsak/btsak_security.c 
b/wireless/bluetooth/btsak/btsak_security.c
index 853fde7cd..ee60dca92 100644
--- a/wireless/bluetooth/btsak/btsak_security.c
+++ b/wireless/bluetooth/btsak/btsak_security.c
@@ -146,7 +146,7 @@ void btsak_cmd_security(FAR struct btsak_s *btsak, int argc,
   /* The first argument must be an address of the form xx:xx:xx:xx:xx:xx */
 
   memset(&btreq, 0, sizeof(struct btreq_s));
-  strncpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
+  strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
 
   ret = btsak_str2addr(argv[1], btreq.btr_secaddr.val);
   if (ret < 0)
diff --git a/wireless/ieee802154/i8sak/i8sak_events.c 
b/wireless/ieee802154/i8sak/i8sak_events.c
index 25b42cf73..b6d22d1dc 100644
--- a/wireless/ieee802154/i8sak/i8sak_events.c
+++ b/wireless/ieee802154/i8sak/i8sak_events.c
@@ -76,7 +76,7 @@ static pthread_addr_t i8sak_eventthread(pthread_addr_t arg)
   else if (i8sak->mode == I8SAK_MODE_NETIF)
     {
       netarg.u.enable = true;
-      strncpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
+      strlcpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
       ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS,
                   (unsigned long)((uintptr_t)&netarg));
     }
@@ -186,7 +186,7 @@ static pthread_addr_t i8sak_eventthread(pthread_addr_t arg)
   else if (i8sak->mode == I8SAK_MODE_NETIF)
     {
       netarg.u.enable = false;
-      strncpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
+      strlcpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
       ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS,
                   (unsigned long)((uintptr_t)&netarg));
     }
diff --git a/wireless/ieee802154/libmac/sixlowpan_assocreq.c 
b/wireless/ieee802154/libmac/sixlowpan_assocreq.c
index 0555d84fb..d81a61e6f 100644
--- a/wireless/ieee802154/libmac/sixlowpan_assocreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_assocreq.c
@@ -45,7 +45,7 @@ int sixlowpan_assoc_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.assocreq, req, sizeof(struct ieee802154_assoc_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_assocresp.c 
b/wireless/ieee802154/libmac/sixlowpan_assocresp.c
index 9a933cf5a..f6c325af4 100644
--- a/wireless/ieee802154/libmac/sixlowpan_assocresp.c
+++ b/wireless/ieee802154/libmac/sixlowpan_assocresp.c
@@ -45,7 +45,7 @@ int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.assocresp, resp, sizeof(struct ieee802154_assoc_resp_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_RESPONSE,
diff --git a/wireless/ieee802154/libmac/sixlowpan_disassocreq.c 
b/wireless/ieee802154/libmac/sixlowpan_disassocreq.c
index c52406d4f..e17939fb4 100644
--- a/wireless/ieee802154/libmac/sixlowpan_disassocreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_disassocreq.c
@@ -45,7 +45,7 @@ int sixlowpan_desassoc_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.disassocreq, req, sizeof(struct ieee802154_disassoc_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_DISASSOC_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_getreq.c 
b/wireless/ieee802154/libmac/sixlowpan_getreq.c
index 9f07f5ca1..3d246a274 100644
--- a/wireless/ieee802154/libmac/sixlowpan_getreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_getreq.c
@@ -45,7 +45,7 @@ int sixlowpan_get_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
 
   /* We must use a shadow arg to perform the operation as we must add the
    * network interface name to the front of the argument.
diff --git a/wireless/ieee802154/libmac/sixlowpan_gtsreq.c 
b/wireless/ieee802154/libmac/sixlowpan_gtsreq.c
index bb47165cd..d33742c2f 100644
--- a/wireless/ieee802154/libmac/sixlowpan_gtsreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_gtsreq.c
@@ -45,7 +45,7 @@ int sixlowpan_gts_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.gtsreq, req, sizeof(struct ieee802154_gts_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_GTS_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_orphanresp.c 
b/wireless/ieee802154/libmac/sixlowpan_orphanresp.c
index fc77831b5..25116c421 100644
--- a/wireless/ieee802154/libmac/sixlowpan_orphanresp.c
+++ b/wireless/ieee802154/libmac/sixlowpan_orphanresp.c
@@ -45,7 +45,7 @@ int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
 
   ret = ioctl(sock, MAC802154IOC_MLME_ORPHAN_RESPONSE,
               (unsigned long)((uintptr_t)&arg));
diff --git a/wireless/ieee802154/libmac/sixlowpan_pollreq.c 
b/wireless/ieee802154/libmac/sixlowpan_pollreq.c
index 0afa0e461..84dc31a53 100644
--- a/wireless/ieee802154/libmac/sixlowpan_pollreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_pollreq.c
@@ -45,7 +45,7 @@ int sixlowpan_poll_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.pollreq, req, sizeof(struct ieee802154_poll_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_POLL_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_resetreq.c 
b/wireless/ieee802154/libmac/sixlowpan_resetreq.c
index f13e74123..84e182942 100644
--- a/wireless/ieee802154/libmac/sixlowpan_resetreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_resetreq.c
@@ -44,7 +44,7 @@ int sixlowpan_reset_req(int sock, FAR const char *ifname, 
bool resetattr)
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   arg.u.resetreq.resetattr = resetattr;
 
   ret = ioctl(sock, MAC802154IOC_MLME_RESET_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_rxenabreq.c 
b/wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
index 8af278644..4165661cc 100644
--- a/wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_rxenabreq.c
@@ -45,7 +45,7 @@ int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.rxenabreq, req, sizeof(struct ieee802154_rxenable_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_RXENABLE_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_scanreq.c 
b/wireless/ieee802154/libmac/sixlowpan_scanreq.c
index 041117f06..b39124bdc 100644
--- a/wireless/ieee802154/libmac/sixlowpan_scanreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_scanreq.c
@@ -45,7 +45,7 @@ int sixlowpan_scan_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.scanreq, req, sizeof(struct ieee802154_scan_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_SCAN_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_setreq.c 
b/wireless/ieee802154/libmac/sixlowpan_setreq.c
index ab67f2c97..f115a74ba 100644
--- a/wireless/ieee802154/libmac/sixlowpan_setreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_setreq.c
@@ -45,7 +45,7 @@ int sixlowpan_set_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.setreq, req, sizeof(struct ieee802154_set_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_SET_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_startreq.c 
b/wireless/ieee802154/libmac/sixlowpan_startreq.c
index 426445d5f..36203e7bc 100644
--- a/wireless/ieee802154/libmac/sixlowpan_startreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_startreq.c
@@ -45,7 +45,7 @@ int sixlowpan_start_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.startreq, req, sizeof(struct ieee802154_start_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_START_REQUEST,
diff --git a/wireless/ieee802154/libmac/sixlowpan_syncreq.c 
b/wireless/ieee802154/libmac/sixlowpan_syncreq.c
index 1a6ded6d6..f3f5af819 100644
--- a/wireless/ieee802154/libmac/sixlowpan_syncreq.c
+++ b/wireless/ieee802154/libmac/sixlowpan_syncreq.c
@@ -45,7 +45,7 @@ int sixlowpan_sync_req(int sock, FAR const char *ifname,
   struct ieee802154_netmac_s arg;
   int ret;
 
-  strncpy(arg.ifr_name, ifname, IFNAMSIZ);
+  strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
   memcpy(&arg.u.syncreq, req, sizeof(struct ieee802154_sync_req_s));
 
   ret = ioctl(sock, MAC802154IOC_MLME_SYNC_REQUEST,

Reply via email to