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 <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-07 19:33:52 +08:00 committed by Xiang Xiao
parent f102f6f405
commit 8ad4ae5508
28 changed files with 182 additions and 130 deletions

View File

@ -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 * cansend.c - send CAN-frames via CAN_RAW sockets
* *
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
@ -40,7 +61,11 @@
* *
* Send feedback to <linux-can@vger.kernel.org> * Send feedback to <linux-can@vger.kernel.org>
* *
*/ ****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -58,112 +83,141 @@
static void print_usage_send(char *prg) static void print_usage_send(char *prg)
{ {
fprintf(stderr, "%s - send CAN-frames via CAN_RAW sockets.\n", prg); fprintf(stderr, "%s - send CAN-frames via CAN_RAW sockets.\n", prg);
fprintf(stderr, "\nUsage: %s <device> <can_frame>.\n", prg); fprintf(stderr, "\nUsage: %s <device> <can_frame>.\n", prg);
fprintf(stderr, "\n<can_frame>:\n"); fprintf(stderr, "\n<can_frame>:\n");
fprintf(stderr, " <can_id>#{data} for 'classic' CAN 2.0 data frames\n"); fprintf(stderr,
fprintf(stderr, " <can_id>#R{len} for 'classic' CAN 2.0 data frames\n"); " <can_id>#{data} ""for 'classic' CAN 2.0 data frames\n");
fprintf(stderr, " <can_id>##<flags>{data} for CAN FD frames\n\n"); fprintf(stderr,
fprintf(stderr, "<can_id>:\n" " <can_id>#R{len} for 'classic' CAN 2.0 data frames\n");
" 3 (SFF) or 8 (EFF) hex chars\n"); fprintf(stderr,
fprintf(stderr, "{data}:\n" " <can_id>##<flags>{data} for CAN FD frames\n\n");
" 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')\n"); fprintf(stderr, "<can_id>:\n"
fprintf(stderr, "{len}:\n" " 3 (SFF) or 8 (EFF) hex chars\n");
" an optional 0..8 value as RTR frames can contain a valid dlc field\n"); fprintf(stderr, "{data}:\n"
fprintf(stderr, "<flags>:\n" " 0..8 (0..64 CAN FD) ASCII hex-values "
" a single ASCII Hex value (0 .. F) which defines canfd_frame.flags\n\n"); "(optionally separated by '.')\n");
fprintf(stderr, "Examples:\n"); fprintf(stderr, "{len}:\n"
fprintf(stderr, " 5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344 /\n" " an optional 0..8 value "
" 1F334455#1122334455667788 / 123#R / 00000123#R3\n\n"); "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 main(int argc, char **argv)
{ {
int s; /* can raw socket */ /* 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 */ int s;
if (argc != 3) { int required_mtu;
print_usage_send(argv[0]); int mtu;
return 1; int enable_canfd = 1;
} struct sockaddr_can addr;
struct canfd_frame frame;
struct ifreq ifr;
/* parse CAN frame */ /* check command line options */
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 (argc != 3)
if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { {
perror("socket"); print_usage_send(argv[0]);
return 1; return 1;
} }
strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1); /* parse CAN frame */
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)); required_mtu = parse_canframe(argv[2], &frame);
addr.can_family = AF_CAN; if (!required_mtu)
addr.can_ifindex = ifr.ifr_ifindex; {
fprintf(stderr, "\nWrong CAN-frame format!\n\n");
print_usage_send(argv[0]);
return 1;
}
if (required_mtu > (int)CAN_MTU) { /* open socket */
/* check if the frame fits into the CAN netdevice */ if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0)
if (ioctl(s, SIOCGIFMTU, &ifr) < 0) { {
perror("SIOCGIFMTU"); perror("socket");
return 1; return 1;
} }
mtu = ifr.ifr_mtu;
if (mtu != CANFD_MTU) { strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
printf("CAN interface is not CAN FD capable - sorry.\n"); ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
return 1; if (!ifr.ifr_ifindex)
} {
perror("if_nametoindex");
return 1;
}
/* interface is ok - try to switch the socket into CAN FD mode */ memset(&addr, 0, sizeof(addr));
if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_FD_FRAMES, addr.can_family = AF_CAN;
&enable_canfd, sizeof(enable_canfd))){ addr.can_ifindex = ifr.ifr_ifindex;
printf("error when enabling CAN FD support\n");
return 1;
}
/* ensure discrete CAN FD length values 0..8, 12, 16, 20, 24, 32, 64 */ if (required_mtu > (int)CAN_MTU)
frame.len = can_dlc2len(can_len2dlc(frame.len)); {
} /* check if the frame fits into the CAN netdevice */
/* disable default receive filter on this RAW socket */ if (ioctl(s, SIOCGIFMTU, &ifr) < 0)
/* 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 */ perror("SIOCGIFMTU");
/* little (really a very little!) CPU usage. */ return 1;
setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0); }
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { mtu = ifr.ifr_mtu;
perror("bind");
return 1;
}
/* send frame */ if (mtu != CANFD_MTU)
if (write(s, &frame, required_mtu) != required_mtu) { {
perror("write"); printf("CAN interface is not CAN FD capable - sorry.\n");
return 1; return 1;
} }
close(s); /* interface is ok - try to switch the socket into CAN FD mode */
return 0; 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;
} }

View File

@ -361,8 +361,7 @@ int main(int argc, char *argv[])
/* set the device name */ /* set the device name */
strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1); strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
ifr.ifr_ifru.ifru_can_data.arbi_bitrate = ifr.ifr_ifru.ifru_can_data.arbi_bitrate =
canspeed / 1000; /* Convert bit/s to kbit/s */ canspeed / 1000; /* Convert bit/s to kbit/s */

View File

@ -49,8 +49,7 @@ int16_t socketcanopen(canardsocketinstance *ins,
return -1; return -1;
} }
strncpy(ifr.ifr_name, can_iface_name, IFNAMSIZ - 1); strlcpy(ifr.ifr_name, can_iface_name, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name); ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name);
if (!ifr.ifr_ifindex) if (!ifr.ifr_ifindex)

View File

@ -347,7 +347,7 @@ static inline int discover_openlistener(void)
/* Get the IP address of the selected device */ /* 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); ret = ioctl(sockfd, SIOCGIFADDR, (unsigned long)&req);
if (ret < 0) if (ret < 0)
{ {

View File

@ -786,7 +786,7 @@ static int netinit_monitor(void)
/* Configure to receive a signal on changes in link status */ /* Configure to receive a signal on changes in link status */
memset(&ifr, 0, sizeof(struct ifreq)); 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_notify = SIGEV_SIGNAL;
ifr.ifr_mii_notify_event.sigev_signo = CONFIG_NETINIT_SIGNO; ifr.ifr_mii_notify_event.sigev_signo = CONFIG_NETINIT_SIGNO;

View File

@ -165,7 +165,7 @@ static int _netlib_ipv4adaptor(in_addr_t destipaddr,
/* Get the network mask */ /* 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)); ret = ioctl(sd, SIOCGIFNETMASK, (unsigned long)((uintptr_t)&maskreq));
if (ret < 0) if (ret < 0)

View File

@ -123,7 +123,7 @@ static int tun_alloc(char *dev)
ifr.ifr_flags = IFF_TUN; ifr.ifr_flags = IFF_TUN;
if (*dev) if (*dev)
{ {
strncpy(ifr.ifr_name, dev, IFNAMSIZ); strlcpy(ifr.ifr_name, dev, IFNAMSIZ);
} }
if ((errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr)) < 0) if ((errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr)) < 0)

View File

@ -83,7 +83,7 @@ int get_phy_id(void)
/* Prepare ifreq */ /* Prepare ifreq */
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); strlcpy(ifr.ifr_name, "eth0", IFNAMSIZ);
ret = ioctl(g_listen_fd, SIOCGMIIPHY, (unsigned long) &ifr); 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; int ret;
struct ifreq ifr; 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_phy_id = phy_id;
ifr.ifr_mii_reg_num = reg_num; 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; int ret;
struct ifreq ifr; 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_phy_id = phy_id;
ifr.ifr_mii_reg_num = reg_num; ifr.ifr_mii_reg_num = reg_num;

View File

@ -126,7 +126,7 @@ static void btsak_cmd_advertisestart(FAR struct btsak_s *btsak,
strcpy((FAR char *)sd[1].data, "btsak"); strcpy((FAR char *)sd[1].data, "btsak");
memset(&btreq, 0, sizeof(struct btreq_s)); 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_advtype = BT_LE_ADV_IND;
btreq.btr_advad = ad; btreq.btr_advad = ad;
btreq.btr_advsd = sd; 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 */ /* Perform the IOCTL to stop advertising */
memset(&btreq, 0, sizeof(struct btreq_s)); 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) if (sockfd >= 0)

View File

@ -105,7 +105,7 @@ void btsak_cmd_features(FAR struct btsak_s *btsak,
/* Perform the IOCTL to stop advertising */ /* Perform the IOCTL to stop advertising */
memset(&btreq, 0, sizeof(struct btreq_s)); 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) if (sockfd >= 0)

View File

@ -84,7 +84,7 @@ static void btsak_cmd_discover_common(FAR struct btsak_s *btsak,
btsak_gatt_showusage(btsak->progname, argv[0], EXIT_FAILURE); 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; btreq.btr_dtype = (uint8_t)type;
ret = btsak_str2addr(argv[1], btreq.btr_dpeer.val); 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 */ /* 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) 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 */ /* 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_rdsize = HCI_GATTRD_DATA;
btreq.btr_rddata = 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 */ /* 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) 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 */ /* 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) if (sockfd >= 0)

View File

@ -91,7 +91,7 @@ void btsak_cmd_info(FAR struct btsak_s *btsak, int argc, FAR char *argv[])
/* Perform the IOCTL to stop advertising */ /* Perform the IOCTL to stop advertising */
memset(&btreq, 0, sizeof(struct btreq_s)); 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) if (sockfd >= 0)

View File

@ -84,7 +84,7 @@ static void btsak_cmd_scanstart(FAR struct btsak_s *btsak, FAR char *cmd,
int ret; int ret;
memset(&btreq, 0, sizeof(struct btreq_s)); 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 */ /* 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 */ /* Perform the IOCTL to get the scan results so far */
memset(&btreq, 0, sizeof(struct btreq_s)); 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_nrsp = 5;
btreq.btr_rsp = result; 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. */ /* Perform the IOCTL to stop scanning and flush any buffered responses. */
memset(&btreq, 0, sizeof(struct btreq_s)); 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); sockfd = btsak_socket(btsak);
if (sockfd >= 0) if (sockfd >= 0)

View File

@ -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 */ /* The first argument must be an address of the form xx:xx:xx:xx:xx:xx */
memset(&btreq, 0, sizeof(struct btreq_s)); 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); ret = btsak_str2addr(argv[1], btreq.btr_secaddr.val);
if (ret < 0) if (ret < 0)

View File

@ -76,7 +76,7 @@ static pthread_addr_t i8sak_eventthread(pthread_addr_t arg)
else if (i8sak->mode == I8SAK_MODE_NETIF) else if (i8sak->mode == I8SAK_MODE_NETIF)
{ {
netarg.u.enable = true; netarg.u.enable = true;
strncpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ); strlcpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS, ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS,
(unsigned long)((uintptr_t)&netarg)); (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) else if (i8sak->mode == I8SAK_MODE_NETIF)
{ {
netarg.u.enable = false; netarg.u.enable = false;
strncpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ); strlcpy(netarg.ifr_name, i8sak->ifname, IFNAMSIZ);
ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS, ioctl(i8sak->fd, MAC802154IOC_ENABLE_EVENTS,
(unsigned long)((uintptr_t)&netarg)); (unsigned long)((uintptr_t)&netarg));
} }

View File

@ -45,7 +45,7 @@ int sixlowpan_assoc_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.assocreq, req, sizeof(struct ieee802154_assoc_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_assoc_resp(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.assocresp, resp, sizeof(struct ieee802154_assoc_resp_s));
ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_RESPONSE, ret = ioctl(sock, MAC802154IOC_MLME_ASSOC_RESPONSE,

View File

@ -45,7 +45,7 @@ int sixlowpan_desassoc_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.disassocreq, req, sizeof(struct ieee802154_disassoc_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_DISASSOC_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_DISASSOC_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_get_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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 /* We must use a shadow arg to perform the operation as we must add the
* network interface name to the front of the argument. * network interface name to the front of the argument.

View File

@ -45,7 +45,7 @@ int sixlowpan_gts_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.gtsreq, req, sizeof(struct ieee802154_gts_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_GTS_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_GTS_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_orphan_resp(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ); strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(sock, MAC802154IOC_MLME_ORPHAN_RESPONSE, ret = ioctl(sock, MAC802154IOC_MLME_ORPHAN_RESPONSE,
(unsigned long)((uintptr_t)&arg)); (unsigned long)((uintptr_t)&arg));

View File

@ -45,7 +45,7 @@ int sixlowpan_poll_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.pollreq, req, sizeof(struct ieee802154_poll_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_POLL_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_POLL_REQUEST,

View File

@ -44,7 +44,7 @@ int sixlowpan_reset_req(int sock, FAR const char *ifname, bool resetattr)
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; int ret;
strncpy(arg.ifr_name, ifname, IFNAMSIZ); strlcpy(arg.ifr_name, ifname, IFNAMSIZ);
arg.u.resetreq.resetattr = resetattr; arg.u.resetreq.resetattr = resetattr;
ret = ioctl(sock, MAC802154IOC_MLME_RESET_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_RESET_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_rxenable_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.rxenabreq, req, sizeof(struct ieee802154_rxenable_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_RXENABLE_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_RXENABLE_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_scan_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.scanreq, req, sizeof(struct ieee802154_scan_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SCAN_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_SCAN_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_set_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.setreq, req, sizeof(struct ieee802154_set_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SET_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_SET_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_start_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.startreq, req, sizeof(struct ieee802154_start_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_START_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_START_REQUEST,

View File

@ -45,7 +45,7 @@ int sixlowpan_sync_req(int sock, FAR const char *ifname,
struct ieee802154_netmac_s arg; struct ieee802154_netmac_s arg;
int ret; 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)); memcpy(&arg.u.syncreq, req, sizeof(struct ieee802154_sync_req_s));
ret = ioctl(sock, MAC802154IOC_MLME_SYNC_REQUEST, ret = ioctl(sock, MAC802154IOC_MLME_SYNC_REQUEST,