From patchwork Thu Jul 12 14:48:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1189311 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D06E8DFFFE for ; Thu, 12 Jul 2012 14:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933965Ab2GLOsp (ORCPT ); Thu, 12 Jul 2012 10:48:45 -0400 Received: from acsinet15.oracle.com ([141.146.126.227]:21700 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932530Ab2GLOso (ORCPT ); Thu, 12 Jul 2012 10:48:44 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q6CEmeeO026051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Jul 2012 14:48:40 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q6CEmdIZ026156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Jul 2012 14:48:39 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q6CEmdfp017057; Thu, 12 Jul 2012 09:48:39 -0500 Received: from elgon.mountain (/41.139.221.94) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Jul 2012 07:48:38 -0700 Date: Thu, 12 Jul 2012 17:48:32 +0300 From: Dan Carpenter To: "Michael S. Tsirkin" , Nicholas Bellinger Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, kernel-janitors@vger.kernel.org Subject: [patch 2/3 -next] tcm_vhost: strlen() doesn't count the terminator Message-ID: <20120712144831.GE24202@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We do snprintf() from "page" to a buffer with TCM_VHOST_NAMELEN characters so the current code will silently truncate the last character. Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index d217bed..57d39c5 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -1254,7 +1254,7 @@ static ssize_t tcm_vhost_tpg_store_nexus( * the fabric protocol_id set in tcm_vhost_make_tport(), and call * tcm_vhost_make_nexus(). */ - if (strlen(page) > TCM_VHOST_NAMELEN) { + if (strlen(page) >= TCM_VHOST_NAMELEN) { pr_err("Emulated NAA Sas Address: %s, exceeds" " max: %d\n", page, TCM_VHOST_NAMELEN); return -EINVAL;