From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2E46D7CA3 for ; Wed, 18 Apr 2018 18:58:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2018 09:58:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,466,1517904000"; d="scan'208";a="34637331" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by orsmga008.jf.intel.com with ESMTP; 18 Apr 2018 09:58:15 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: jasvinder.singh@intel.com, Reshma Pattan Date: Wed, 18 Apr 2018 17:58:08 +0100 Message-Id: <1524070690-12000-2-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1524070690-12000-1-git-send-email-reshma.pattan@intel.com> References: <1524070690-12000-1-git-send-email-reshma.pattan@intel.com> 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: Wed, 18 Apr 2018 16:58:17 -0000 Copying source string of length equal to sizeof(kni->name) will not append the NULL to destination string. Using strlcpy in place of strncpy fixes this issue as strlcpy guarantees NULL termination. Coverity issue: 272562 Fixes: 9a408cc8ac ("examples/ip_pipeline: add KNI object") CC: jasvinder.singh@intel.com Signed-off-by: Reshma Pattan --- examples/ip_pipeline/kni.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index ed5f8942e..7e5ff0543 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -7,6 +7,7 @@ #include #include +#include #include "kni.h" #include "mempool.h" @@ -153,7 +154,7 @@ kni_create(const char *name, struct kni_params *params) return NULL; /* Node fill in */ - strncpy(kni->name, name, sizeof(kni->name)); + strlcpy(kni->name, name, sizeof(kni->name)); kni->k = k; /* Node add to list */ -- 2.14.3