From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CFA57A04E7; Sun, 29 Nov 2020 18:56:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 16055C9C4; Sun, 29 Nov 2020 18:55:06 +0100 (CET) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 07E43C97A for ; Sun, 29 Nov 2020 18:54:58 +0100 (CET) Received: by mail-pf1-f196.google.com with SMTP id 131so8838816pfb.9 for ; Sun, 29 Nov 2020 09:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=xN/X9zn4oIUiO/HSRu7hnzwnOBfV+4k2sw2LGVLsPti+a6omkIJxOWKf3s7dH1Shsd QYnh46SU3V3oSFbaTtM3SlxKzPcs0DW6JUNHMLKh7t++8n1hTG0/wlijMStShxOiHxnR y1pM7sg4/A2ZWUdhRgDcq+Peb8k0kGPr2Iix9xONgW2/8kU/IfD1dUAZ8xUoiw874iyk 4G+n/itzyYfmLmCW428gj+sDMW7kYaC1QELdiM/NcsbY0dAzrEznYnVu5bS1IyU29R92 HD1n4vFyCn0kM0SJcqsM7B5buCi2mlsXe/5pTC6rEXnaneWQ7OCpkE8dlY1YqcINIodg oqAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=RrUe+ztd2vV+OV4Lb+AJbNIT7+7/HKXaO4EScx5Bo0CNlVhkDPRvSIDro5xKEpGxPj DgdTxpvWD9Q3cRYf+dcLxuc8xZkbVQilFoBBnRmT0HQB1VdoYEI+IFY3mLc3DWYBq30L pgejx2nXlZcjw+UOptPhha9dWvuWgrndLf4chf1ypb2CvZ0cegxvKMVK/EEpyRIXt3BO QFYu8oQ4hvREGc+3YlHHaW17zI6WLhXh6Hk9hw/EBprUVMg7GR0E0DpxyTDwthlL53Ml COy/c8KGVNKaLXls/qH1E462oYdwYjfcdWImigCJye00u9ur2gKhIAbxdBpfQmVCiHK/ 8b7w== X-Gm-Message-State: AOAM531cvL3wLGCvB5wBwNDjBFKfrky6Z7l3vjxkVNU9bKOm+eiocI8R 63ID+5lBH2DPVsrZ+vFQSQlK/08ZCXfkrKDI X-Google-Smtp-Source: ABdhPJzZki1Y2Y87Lh9IVBi4Q7jP08af5B00xuCu8ELdDDrUAVmg7/rI1IOpQe9k8lIs+yNWaBICSQ== X-Received: by 2002:a17:90b:4785:: with SMTP id hz5mr4035335pjb.157.1606672495765; Sun, 29 Nov 2020 09:54:55 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sun, 29 Nov 2020 09:54:36 -0800 Message-Id: <20201129175437.15346-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 4/5] misc: fix compiler warning in ifstat and nstat X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The code here was doing strncpy() in a way that causes gcc 10 warning about possible string overflow. Just use strlcpy() which will null terminate and bound the string as expected. This has existed since start of git era so no Fixes tag. Signed-off-by: Stephen Hemminger --- misc/ifstat.c | 2 +- misc/nstat.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index c05183d79a13..d4a33429dc50 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -251,7 +251,7 @@ static void load_raw_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - strncpy(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf+1, sizeof(info_source)); continue; } if ((n = malloc(sizeof(*n))) == NULL) diff --git a/misc/nstat.c b/misc/nstat.c index 6fdd316cce84..ecdd4ce8266d 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -136,8 +136,7 @@ static void load_good_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - info_source[0] = 0; - strncat(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf + 1, sizeof(info_source)); continue; } /* idbuf is as big as buf, so this is safe */ -- 2.29.2