From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Laatz Subject: [PATCH] examples/ip_pipeline: fix buffer not null terminated Date: Thu, 19 Apr 2018 12:01:25 +0100 Message-ID: <20180419110125.7759-1-kevin.laatz@intel.com> Cc: cristian.dumitrescu@intel.com, Kevin Laatz , jasvinder.singh@intel.com To: dev@dpdk.org Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D30656A71 for ; Thu, 19 Apr 2018 13:01:30 +0200 (CEST) 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's string is equal to the sizeof(mempool->name). Using strlcpy in place of strncpy fixes this issue as strlcpy guarantees NULL termination. Coverity issue: 272588 Fixes: 6bfe74f8c93e ("examples/ip_pipeline: add mempool object") Cc: jasvinder.singh@intel.com Signed-off-by: Kevin Laatz --- examples/ip_pipeline/mempool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/mempool.c b/examples/ip_pipeline/mempool.c index 33b9243..f5d2a7d 100644 --- a/examples/ip_pipeline/mempool.c +++ b/examples/ip_pipeline/mempool.c @@ -6,6 +6,7 @@ #include #include +#include #include "mempool.h" @@ -70,7 +71,7 @@ mempool_create(const char *name, struct mempool_params *params) } /* Node fill in */ - strncpy(mempool->name, name, sizeof(mempool->name)); + strlcpy(mempool->name, name, sizeof(mempool->name)); mempool->m = m; mempool->buffer_size = params->buffer_size; -- 2.9.5