From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id EF6DBAAD6 for ; Fri, 18 May 2018 13:38:17 +0200 (CEST) From: Andy Green To: stable@dpdk.org Date: Fri, 18 May 2018 19:38:14 +0800 Message-ID: <152664349400.25528.10851185997497857930.stgit@localhost.localdomain> In-Reply-To: <152664333397.25528.18140247166845268675.stgit@localhost.localdomain> References: <152664333397.25528.18140247166845268675.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [dpdk-stable] [PATCH 5/5] net/sfc: make sure that stats name is nul-terminated X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 May 2018 11:38:18 -0000 Fixes: 73280c1e4ff2 ("net/sfc: support xstats retrieval by ID") Fixes: 7b9891769f4b ("net/sfc: support extended statistics") Cc: stable@dpdk.org Signed-off-by: Andy Green Acked-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2f5f86f84..7373ebeec 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "efx.h" @@ -666,7 +667,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev, for (i = 0; i < EFX_MAC_NSTATS; ++i) { if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { if (xstats_names != NULL && nstats < xstats_count) - strncpy(xstats_names[nstats].name, + strlcpy(xstats_names[nstats].name, efx_mac_stat_name(sa->nic, i), sizeof(xstats_names[0].name)); nstats++; @@ -744,9 +745,8 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, if ((ids == NULL) || (ids[nb_written] == nb_supported)) { char *name = xstats_names[nb_written++].name; - strncpy(name, efx_mac_stat_name(sa->nic, i), + strlcpy(name, efx_mac_stat_name(sa->nic, i), sizeof(xstats_names[0].name)); - name[sizeof(xstats_names[0].name) - 1] = '\0'; } ++nb_supported;