From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2018 04:01:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,468,1517904000"; d="scan'208";a="221688977" Received: from silpixa00397517.ir.intel.com (HELO silpixa00397517.ger.corp.intel.com) ([10.237.222.54]) by fmsmga006.fm.intel.com with ESMTP; 19 Apr 2018 04:01:28 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, Kevin Laatz , jasvinder.singh@intel.com Date: Thu, 19 Apr 2018 12:01:25 +0100 Message-Id: <20180419110125.7759-1-kevin.laatz@intel.com> X-Mailer: git-send-email 2.9.5 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: , X-List-Received-Date: Thu, 19 Apr 2018 11:01:31 -0000 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