From patchwork Mon Apr 16 16:57:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 38251 X-Patchwork-Delegate: cristian.dumitrescu@intel.com 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 CC83FCF7A; Mon, 16 Apr 2018 18:57:13 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 003A48E5F for ; Mon, 16 Apr 2018 18:57:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 09:57:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="33789160" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga007.jf.intel.com with ESMTP; 16 Apr 2018 09:57:09 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Mon, 16 Apr 2018 17:57:08 +0100 Message-Id: <20180416165708.120699-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: fix buffer not null terminated 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" The destination string may not have a null termination if the source string's length is equal to the sizeof(link->name). Fix by replacing strncpy with strlcpy that guarantees NULL-termination. Coverty issue: 272594 Fixes: 133c2c6565d6 ("examples/ip_pipeline: add link object") Signed-off-by: Jasvinder Singh --- examples/ip_pipeline/link.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c index 26ff41b..b8a431f 100644 --- a/examples/ip_pipeline/link.c +++ b/examples/ip_pipeline/link.c @@ -6,6 +6,7 @@ #include #include +#include #include "link.h" #include "mempool.h" @@ -236,7 +237,7 @@ link_create(const char *name, struct link_params *params) } /* Node fill in */ - strncpy(link->name, name, sizeof(link->name)); + strlcpy(link->name, name, sizeof(link->name)); link->port_id = port_id; link->n_rxq = params->rx.n_queues; link->n_txq = params->tx.n_queues;