From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f66.google.com ([74.125.83.66]:35893 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbeCTU3S (ORCPT ); Tue, 20 Mar 2018 16:29:18 -0400 Received: by mail-pg0-f66.google.com with SMTP id i14so1094350pgv.3 for ; Tue, 20 Mar 2018 13:29:18 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 v2 4/9] tunnel: use strlcpy to avoid strncpy warnings Date: Tue, 20 Mar 2018 13:29:04 -0700 Message-Id: <20180320202909.22166-5-stephen@networkplumber.org> In-Reply-To: <20180320202909.22166-1-stephen@networkplumber.org> References: <20180320202909.22166-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org List-ID: Fixes warnings about strncpy size by using strlcpy. tunnel.c: In function ‘tnl_gen_ioctl’: tunnel.c:145:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] strncpy(ifr.ifr_name, name, IFNAMSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Stephen Hemminger --- ip/tunnel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ip/tunnel.c b/ip/tunnel.c index 948d5f7c90f6..abd9fa2ffe0c 100644 --- a/ip/tunnel.c +++ b/ip/tunnel.c @@ -64,7 +64,7 @@ int tnl_get_ioctl(const char *basedev, void *p) int fd; int err; - strncpy(ifr.ifr_name, basedev, IFNAMSIZ); + strlcpy(ifr.ifr_name, basedev, IFNAMSIZ); ifr.ifr_ifru.ifru_data = (void *)p; fd = socket(preferred_family, SOCK_DGRAM, 0); @@ -89,9 +89,9 @@ int tnl_add_ioctl(int cmd, const char *basedev, const char *name, void *p) int err; if (cmd == SIOCCHGTUNNEL && name[0]) - strncpy(ifr.ifr_name, name, IFNAMSIZ); + strlcpy(ifr.ifr_name, name, IFNAMSIZ); else - strncpy(ifr.ifr_name, basedev, IFNAMSIZ); + strlcpy(ifr.ifr_name, basedev, IFNAMSIZ); ifr.ifr_ifru.ifru_data = p; fd = socket(preferred_family, SOCK_DGRAM, 0); @@ -115,9 +115,9 @@ int tnl_del_ioctl(const char *basedev, const char *name, void *p) int err; if (name[0]) - strncpy(ifr.ifr_name, name, IFNAMSIZ); + strlcpy(ifr.ifr_name, name, IFNAMSIZ); else - strncpy(ifr.ifr_name, basedev, IFNAMSIZ); + strlcpy(ifr.ifr_name, basedev, IFNAMSIZ); ifr.ifr_ifru.ifru_data = p; @@ -142,7 +142,7 @@ static int tnl_gen_ioctl(int cmd, const char *name, int fd; int err; - strncpy(ifr.ifr_name, name, IFNAMSIZ); + strlcpy(ifr.ifr_name, name, IFNAMSIZ); ifr.ifr_ifru.ifru_data = p; fd = socket(preferred_family, SOCK_DGRAM, 0); -- 2.16.2