summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2018-05-14 13:00:47 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2018-05-14 23:32:23 +0200
commited5b98483a30c034ab7ba666af2c26161828323d (patch)
tree731a75fe533869c63fda126b910b86c62896d3dd
parentf28742ba06a83a0bb8f658e12105e975ab7b26d7 (diff)
downloaddpdk-ed5b98483a30c034ab7ba666af2c26161828323d.zip
dpdk-ed5b98483a30c034ab7ba666af2c26161828323d.tar.gz
dpdk-ed5b98483a30c034ab7ba666af2c26161828323d.tar.xz
net/sfc: make sure that stats name is nul-terminated
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 <andy@warmcat.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
-rw-r--r--drivers/net/sfc/sfc_ethdev.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 578af54..1b6499f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -13,6 +13,7 @@
#include <rte_pci.h>
#include <rte_bus_pci.h>
#include <rte_errno.h>
+#include <rte_string_fns.h>
#include "efx.h"
@@ -648,7 +649,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++;
@@ -726,9 +727,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;