From patchwork Tue Sep 19 11:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SebastianX Basierski X-Patchwork-Id: 28946 X-Patchwork-Delegate: yuanhan.liu@linux.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 641774BE1; Tue, 19 Sep 2017 13:47:23 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7DAA837B7 for ; Tue, 19 Sep 2017 13:47:22 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 04:47:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,418,1500966000"; d="scan'208"; a="1173708812" Received: from unknown (HELO Sent) ([10.103.102.64]) by orsmga001.jf.intel.com with SMTP; 19 Sep 2017 04:47:18 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 19 Sep 2017 13:41:17 +0200 From: SebastianX Basierski To: skhare@vmware.com Cc: SebastianX Basierski , jianfeng.tan@intel.com, dev@dpdk.org Date: Tue, 19 Sep 2017 13:41:04 +0200 Message-Id: <1505821264-33518-1-git-send-email-sebastianx.basierski@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] pmd_virtio: 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" Fix calling strncpy with the a maximum size equal of destination array size. Coverity issue: 140732 Fixes: e3b434818bbb ("net/virtio-user: support kernel vhost") Cc: jianfeng.tan@intel.com cc: dev@dpdk.org Signed-off-by: SebastianX Basierski Acked-by: Jianfeng Tan Acked-by: Jianfeng Tan --- drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c index f585de8..689a5cf 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c @@ -95,9 +95,9 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq) ifr.ifr_flags |= IFF_MULTI_QUEUE; if (*p_ifname) - strncpy(ifr.ifr_name, *p_ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, *p_ifname, IFNAMSIZ - 1); else - strncpy(ifr.ifr_name, "tap%d", IFNAMSIZ); + strncpy(ifr.ifr_name, "tap%d", IFNAMSIZ - 1); if (ioctl(tapfd, TUNSETIFF, (void *)&ifr) == -1) { PMD_DRV_LOG(ERR, "TUNSETIFF failed: %s", strerror(errno)); goto error;