Fix error: 'strncpy' specified bound 16 equals destination size
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
5451214d0b
commit
0426c8c09f
@ -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 */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user