From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B27597CFA for ; Tue, 17 Apr 2018 15:17:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 06:17:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,463,1517904000"; d="scan'208";a="38062950" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga002.fm.intel.com with ESMTP; 17 Apr 2018 06:17:20 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Tue, 17 Apr 2018 14:17:19 +0100 Message-Id: <20180417131719.146374-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 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: Tue, 17 Apr 2018 13:17:23 -0000 The destination string may not have a null termination if the source string's length is equal to the sizeof(tap->name). Fix by replacing strncpy with strlcpy that guarantees NULL-termination. Coverty issue: 272603 Fixes: 2f74ae28e23f ("examples/ip_pipeline: add tap object") Signed-off-by: Jasvinder Singh --- examples/ip_pipeline/tap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/ip_pipeline/tap.c b/examples/ip_pipeline/tap.c index 5b34032..a4e10fa 100644 --- a/examples/ip_pipeline/tap.c +++ b/examples/ip_pipeline/tap.c @@ -15,6 +15,8 @@ #include #include +#include + #include "tap.h" #define TAP_DEV "/dev/net/tun" @@ -85,7 +87,7 @@ tap_create(const char *name) return NULL; /* Node fill in */ - strncpy(tap->name, name, sizeof(tap->name)); + strlcpy(tap->name, name, sizeof(tap->name)); tap->fd = fd; /* Node add to list */ -- 2.9.3