From patchwork Tue May 10 16:11:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mrzyglod X-Patchwork-Id: 12658 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 [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 128079AE6; Tue, 10 May 2016 17:10:44 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id B4EC058DF for ; Tue, 10 May 2016 17:10:42 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 10 May 2016 08:10:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,604,1455004800"; d="scan'208";a="976709648" Received: from gklab-246-025.igk.intel.com (HELO Sent) ([10.217.246.25]) by fmsmga002.fm.intel.com with SMTP; 10 May 2016 08:10:39 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 10 May 2016 18:11:21 +0200 From: Daniel Mrzyglod To: huawei.xie@intel.com, yuanhan.liu@linux.intel.com, przemyslaw.czesnowicz@intel.com Cc: dev@dpdk.org, Daniel Mrzyglod Date: Tue, 10 May 2016 18:11:18 +0200 Message-Id: <1462896678-40929-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] vhost: fix buffer not null terminated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix issue reported by Coverity. Coverity ID 124556 If the buffer is treated as a null terminated string in later operations, a buffer overflow or over-read may occur. In vhost_set_ifname: The string buffer may not have a null terminator if the source string's length is equal to the buffer size Fixes: 54292e9520e0 ("vhost: support ifname for vhost-user") Signed-off-by: Daniel Mrzyglod --- lib/librte_vhost/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index d870ad9..f4695af 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -320,6 +320,7 @@ vhost_set_ifname(struct vhost_device_ctx ctx, sizeof(dev->ifname) : if_len; strncpy(dev->ifname, if_name, len); + dev->ifname[sizeof(dev->ifname) - 1] = '\0'; }