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 B910A1CF70 for ; Sun, 13 May 2018 05:24:34 +0200 (CEST) From: Andy Green To: dev@dpdk.org Date: Sun, 13 May 2018 11:24:12 +0800 Message-ID: <152618185248.125230.3244687143464768033.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] bus/ifpga: fix strncpy with wrong length with strlcpy 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: , X-List-Received-Date: Sun, 13 May 2018 03:24:34 -0000 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 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 #include #include +#include #include #include @@ -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)){