From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9EEAAC68C for ; Fri, 24 Jun 2016 18:36:29 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2016 09:36:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,521,1459839600"; d="scan'208";a="982682769" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 24 Jun 2016 09:36:26 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u5OGaP2N022369; Fri, 24 Jun 2016 17:36:25 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u5OGaPF2003947; Fri, 24 Jun 2016 17:36:25 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u5OGaPLO003943; Fri, 24 Jun 2016 17:36:25 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Fri, 24 Jun 2016 17:36:21 +0100 Message-Id: <1466786183-3772-4-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466786183-3772-1-git-send-email-reshma.pattan@intel.com> References: <1466776473-30883-1-git-send-email-reshma.pattan@intel.com> <1466786183-3772-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH v5 3/5] pdump: fix string overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2016 16:36:30 -0000 replaced strncpy with snprintf for safely copying the strings. Cverity issue 127350: string overflow Fixes: 278f945402c5 ("pdump: add new library for packet capture") Signed-off-by: Reshma Pattan --- lib/librte_pdump/rte_pdump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index e3b03a6..ee566cb 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -810,13 +810,15 @@ pdump_prepare_client_request(char *device, uint16_t queue, req.flags = flags; req.op = operation; if ((operation & ENABLE) != 0) { - strncpy(req.data.en_v1.device, device, strlen(device)); + snprintf(req.data.en_v1.device, sizeof(req.data.en_v1.device), + "%s", device); req.data.en_v1.queue = queue; req.data.en_v1.ring = ring; req.data.en_v1.mp = mp; req.data.en_v1.filter = filter; } else { - strncpy(req.data.dis_v1.device, device, strlen(device)); + snprintf(req.data.dis_v1.device, sizeof(req.data.dis_v1.device), + "%s", device); req.data.dis_v1.queue = queue; req.data.dis_v1.ring = NULL; req.data.dis_v1.mp = NULL; -- 2.5.0