From: Jasvinder Singh Subject: [PATCH] examples/ip_pipeline: fix buffer not null terminated Date: Tue, 17 Apr 2018 14:17:19 +0100 Message-ID: <20180417131719.146374-1-jasvinder.singh@intel.com> Cc: cristian.dumitrescu@intel.com To: dev@dpdk.org 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) 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 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