mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 02:48:37 +08:00
fix snprintf truncation warnings
gcc7.1 adds truncation warning, netdev_ifconf.c fix snprintf truncation warnings Signed-off-by: zhangjun21 <zhangjun21@xiaomi.com>
This commit is contained in:
parent
c32c8da761
commit
16124b0926
1 changed files with 4 additions and 1 deletions
|
@ -177,6 +177,7 @@ static int ifconf_ipv6_addr_callback(FAR struct net_driver_s *dev,
|
|||
(FAR struct sockaddr_in6 *)&req->lifr_addr;
|
||||
#ifdef CONFIG_NETDEV_MULTIPLE_IPv6
|
||||
int addr_idx = addr - dev->d_ipv6;
|
||||
char ifname[IFNAMSIZ + 16];
|
||||
|
||||
/* There is space for information about another adapter. Within
|
||||
* each ifreq structure, lifr_name will receive the interface
|
||||
|
@ -188,12 +189,14 @@ static int ifconf_ipv6_addr_callback(FAR struct net_driver_s *dev,
|
|||
{
|
||||
/* eth0:0 represents the second addr on eth0 */
|
||||
|
||||
if (snprintf(req->lifr_name, IFNAMSIZ,
|
||||
if (snprintf(ifname, sizeof(ifname),
|
||||
"%s:%d", dev->d_ifname, addr_idx - 1) >= IFNAMSIZ)
|
||||
{
|
||||
nwarn("WARNING: ifname too long to print %s:%d\n",
|
||||
dev->d_ifname, addr_idx - 1);
|
||||
}
|
||||
|
||||
strlcpy(req->lifr_name, ifname, IFNAMSIZ);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue