From patchwork Sat May 12 01:47:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Green X-Patchwork-Id: 39878 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 02CC31CC07; Sat, 12 May 2018 03:48:04 +0200 (CEST) Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id 294281CC06 for ; Sat, 12 May 2018 03:48:03 +0200 (CEST) From: Andy Green To: dev@dpdk.org Date: Sat, 12 May 2018 09:47:59 +0800 Message-ID: <152608967931.121204.3086768884047081432.stgit@localhost.localdomain> In-Reply-To: <152608956198.121204.14844325841690943774.stgit@localhost.localdomain> References: <152608956198.121204.14844325841690943774.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Subject: [dpdk-dev] [PATCH v5 03/16] bus/pci: replace strncpy dangerous code 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" In function ‘pci_get_kernel_driver_by_path’, inlined from ‘pci_scan_one.isra.1’ at /home/agreen/projects/dpdk/ drivers/bus/pci/linux/pci.c:317:8: /home/agreen/projects/dpdk/drivers/bus/pci/linux/pci.c:57:3: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy(dri_name, name + 1, strlen(name + 1) + 1); Signed-off-by: Andy Green Acked-by: Pablo de Lara Fixes: d9a8cd9595f2 ("pci: add kernel driver type") Cc: stable@dpdk.org --- drivers/bus/pci/linux/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 4630a8057..a73ee49c2 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name) name = strrchr(path, '/'); if (name) { - strncpy(dri_name, name + 1, strlen(name + 1) + 1); + strlcpy(dri_name, name + 1, sizeof(dri_name)); return 0; }