From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Alex Williamson 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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL 2/4] pci-assign: Fix potential read beyond buffer on -EBUSY List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@redhat.com Cc: Peter Maydell , Markus Armbruster , qemu-devel@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;