DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] bus/ifpga: fix strncpy with wrong length with strlcpy
@ 2018-05-13  3:24 Andy Green
  2018-05-13  3:26 ` Andy Green
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Green @ 2018-05-13  3:24 UTC (permalink / raw)
  To: dev

In function ‘ifpga_scan_one’,
    inlined from ‘ifpga_scan’ at /home/agreen/projects/
lagopus/src/dpdk/drivers/bus/ifpga/ifpga_bus.c:229:13:
/home/agreen/projects/lagopus/src/dpdk/drivers/bus/ifpga/
ifpga_bus.c:161:2: error: ‘strncpy’ specified bound 256
equals destination size [-Werror=stringop-truncation]
  strncpy(afu_pr_conf.bs_path, path,
sizeof(afu_pr_conf.bs_path));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~

Signed-off-by: Andy Green <andy@warmcat.com>
Fixes: 05fa3d4a65 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index 16b7e06b6..08b3c8fdd 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -20,6 +20,7 @@
 #include <rte_memzone.h>
 #include <rte_eal.h>
 #include <rte_common.h>
+#include <rte_string_fns.h>
 
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
@@ -158,7 +159,7 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
 		rawdev->dev_ops->dev_start(rawdev))
 		goto free_dev;
 
-	strncpy(afu_pr_conf.bs_path, path, sizeof(afu_pr_conf.bs_path));
+	strlcpy(afu_pr_conf.bs_path, path, sizeof(afu_pr_conf.bs_path));
 	if (rawdev->dev_ops->firmware_load &&
 		rawdev->dev_ops->firmware_load(rawdev,
 				&afu_pr_conf)){

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-13  3:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13  3:24 [dpdk-dev] [PATCH] bus/ifpga: fix strncpy with wrong length with strlcpy Andy Green
2018-05-13  3:26 ` Andy Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).