From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 492AC5F29 for ; Tue, 17 Apr 2018 18:39:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 09:39:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,464,1517904000"; d="scan'208";a="221158316" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga005.fm.intel.com with ESMTP; 17 Apr 2018 09:39:54 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, bruce.richardson@intel.com Date: Tue, 17 Apr 2018 17:39:53 +0100 Message-Id: <20180417163953.72821-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180417132825.148429-1-jasvinder.singh@intel.com> References: <20180417132825.148429-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: , X-List-Received-Date: Tue, 17 Apr 2018 16:39:56 -0000 The destination string may not have a null termination if the source string's length is equal to the sizeof(pipeline->name). Fix by replacing strncpy with strlcpy that guarantees NULL-termination. Coverty issue: 272606 Fixes: d75c371e9b46 ("examples/ip_pipeline: add pipeline object") Signed-off-by: Jasvinder Singh Acked-by: Bruce Richardson --- examples/ip_pipeline/pipeline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c index 76aa1d3..43fe867 100644 --- a/examples/ip_pipeline/pipeline.c +++ b/examples/ip_pipeline/pipeline.c @@ -9,6 +9,7 @@ #include #include +#include #include #ifdef RTE_LIBRTE_KNI #include @@ -129,7 +130,7 @@ pipeline_create(const char *name, struct pipeline_params *params) } /* Node fill in */ - strncpy(pipeline->name, name, sizeof(pipeline->name)); + strlcpy(pipeline->name, name, sizeof(pipeline->name)); pipeline->p = p; pipeline->n_ports_in = 0; pipeline->n_ports_out = 0; -- 2.9.3