From 179d520777dd9f023c37e913e1664dd5d225e568 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 12 Mar 2019 23:36:51 +0200 Subject: [PATCH] drivers: eth: native_posix: Null terminate interface name The interface name is IFNAMSIZ long so we must not copy it full which would overwrite the terminating null byte. Coverity-CID: 195770 Fixes #14419 Signed-off-by: Jukka Rissanen --- drivers/ethernet/eth_native_posix_adapt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ethernet/eth_native_posix_adapt.c b/drivers/ethernet/eth_native_posix_adapt.c index 8045b1d0e0..b34174ba0a 100644 --- a/drivers/ethernet/eth_native_posix_adapt.c +++ b/drivers/ethernet/eth_native_posix_adapt.c @@ -67,7 +67,7 @@ int eth_iface_create(const char *if_name, bool tun_only) #ifdef __linux ifr.ifr_flags = (tun_only ? IFF_TUN : IFF_TAP) | IFF_NO_PI; - strncpy(ifr.ifr_name, if_name, IFNAMSIZ); + strncpy(ifr.ifr_name, if_name, IFNAMSIZ - 1); ret = ioctl(fd, TUNSETIFF, (void *)&ifr); if (ret < 0) {