From patchwork Thu Apr 19 11:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 38519 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 316757CC3; Thu, 19 Apr 2018 13:03:22 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 61EE47CBE for ; Thu, 19 Apr 2018 13:03:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2018 04:03:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,468,1517904000"; d="scan'208";a="33122119" Received: from silpixa00397517.ir.intel.com (HELO silpixa00397517.ger.corp.intel.com) ([10.237.222.54]) by fmsmga007.fm.intel.com with ESMTP; 19 Apr 2018 04:03:18 -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:03:16 +0100 Message-Id: <20180419110316.7939-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: , 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(tmgr_port->name). Using strlcpy in place of strncpy fixes this issue as strlcpy guarantees NULL termination. Coverity issue: 272592 Fixes: 25961ff3bcb9 ("examples/ip_pipeline: add traffic manager object") Cc: jasvinder.singh@intel.com Signed-off-by: Kevin Laatz Reviewed-by: Jasvinder Singh --- examples/ip_pipeline/tmgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/tmgr.c b/examples/ip_pipeline/tmgr.c index b46ca96..40cbf1d 100644 --- a/examples/ip_pipeline/tmgr.c +++ b/examples/ip_pipeline/tmgr.c @@ -4,6 +4,8 @@ #include +#include + #include "tmgr.h" static struct rte_sched_subport_params @@ -148,7 +150,7 @@ tmgr_port_create(const char *name, struct tmgr_port_params *params) } /* Node fill in */ - strncpy(tmgr_port->name, name, sizeof(tmgr_port->name)); + strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name)); tmgr_port->s = s; tmgr_port->n_subports_per_port = params->n_subports_per_port; tmgr_port->n_pipes_per_subport = params->n_pipes_per_subport;