From patchwork Wed Feb 26 18:26:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 324562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FB712C0096 for ; Thu, 27 Feb 2014 05:26:47 +1100 (EST) Received: from localhost ([::1]:42402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIjBs-00043R-RO for incoming@patchwork.ozlabs.org; Wed, 26 Feb 2014 13:26:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIjBL-0003sq-I2 for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:26:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIjBE-0007cd-6n for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:26:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIjBD-0007bj-VX for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:26:04 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1QIQ11U005131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Feb 2014 13:26:02 -0500 Received: from bling.home (ovpn-113-32.phx2.redhat.com [10.3.113.32]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1QIQ1g0005970; Wed, 26 Feb 2014 13:26:01 -0500 From: Alex Williamson To: anthony@redhat.com Date: Wed, 26 Feb 2014 11:26:00 -0700 Message-ID: <20140226182600.8018.17416.stgit@bling.home> In-Reply-To: <20140226182246.8018.81349.stgit@bling.home> References: <20140226182246.8018.81349.stgit@bling.home> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Markus Armbruster , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 2/4] pci-assign: Fix potential read beyond buffer on -EBUSY X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster readlink() doesn't write a terminating null byte. assign_failed_examine() passes the unterminated string to strrchr(). Oops. Terminate it. Spotted by Coverity. Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell Signed-off-by: Alex Williamson --- hw/i386/kvm/pci-assign.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 9686801..a825871 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -743,6 +743,7 @@ static void assign_failed_examine(AssignedDevice *dev) goto fail; } + driver[r] = 0; ns = strrchr(driver, '/'); if (!ns) { goto fail;