From patchwork Tue Jun 7 17:08:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9162055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C9B060801 for ; Tue, 7 Jun 2016 17:09:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB40A28294 for ; Tue, 7 Jun 2016 17:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E030428305; Tue, 7 Jun 2016 17:09:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 75C12282DC for ; Tue, 7 Jun 2016 17:09:09 +0000 (UTC) Received: from localhost ([::1]:51726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAKV2-0005Tr-KW for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 13:09:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAKUh-0005TJ-3Z for qemu-devel@nongnu.org; Tue, 07 Jun 2016 13:08:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAKUb-00079a-Qm for qemu-devel@nongnu.org; Tue, 07 Jun 2016 13:08:45 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAKUb-00079V-JZ for qemu-devel@nongnu.org; Tue, 07 Jun 2016 13:08:41 -0400 Received: by mail-wm0-x243.google.com with SMTP id k184so19386842wme.2 for ; Tue, 07 Jun 2016 10:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WUZbgh0y8wRzqTOJ+Qsa0pYqIzXyRFGRaJQtoB/2rA0=; b=qeUwu8eydRB/MFOzKnoybWR2JHa76uT7YuMucJFma2BHDwDFbUCYzc/Xg42bLs1Sju beYqpCr/gvZnTBHpzDQFuSHkl/vfxSbcXuyrXnMx2gVcg7G9H5dAkVHoxARIgq1RNiEv Ex7ztQpkswDyJHto0F2usJD6jPbHHw5oPSjA435aaykjKvoOoRRrLPzWQwKovIFAfKJ1 o1i05If0upGWz8ZNuw/oeIYvnaJNnIqIY7OzvKdeHsEHfKSbrrPy2/n+iUVK140hgpK2 etwUjq6eDeK2K38Gj5fWp0IgskdM10mckHN/sUaY5JAT3HZg8dAzJh+J6SiJgxPh8698 K0tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WUZbgh0y8wRzqTOJ+Qsa0pYqIzXyRFGRaJQtoB/2rA0=; b=Cn1K1VdqeqzdlobsvQpPtgOsv1hqGByuSzpsoWBmor+9FlCucqkVpKLeL3sdcNmiXy 3ipQ0gt+ZlqJobCVauUP9zQZyeC/t6SAJDbzswqfFe99Y7UbwZ//H9FkpIJPlpIXvDHl OHHQoNVMKSD4gc6j/C4MbeC9U+rciUakXPy82GeeU1OhCi5Nhs+pslr9DMDueo15D4FG wJZYam/GUaTD/IzKqBBhBztDhBS+POL9pOVTW48V5ZLGouqQeTBdqaK8u4Gls5L6RTI8 XdZbuWDV2yiiYxWSSr0gj+2+cz1Qp1xAdiBgIpB0+Jd9eRu96pQRnmTG7NESCm8C2WzQ n2YA== X-Gm-Message-State: ALyK8tKawx0BGDaydGplmTIOyg6bCIT6G4tSelholjI7tYkZgtKgccvXb2xD53zJqG5IJw== X-Received: by 10.195.8.40 with SMTP id dh8mr487036wjd.178.1465319321005; Tue, 07 Jun 2016 10:08:41 -0700 (PDT) Received: from 640k.lan (94-39-188-118.adsl-ull.clienti.tiscali.it. [94.39.188.118]) by smtp.gmail.com with ESMTPSA id o76sm20511305wme.0.2016.06.07.10.08.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 10:08:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 7 Jun 2016 19:08:34 +0200 Message-Id: <1465319317-50519-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1465319317-50519-1-git-send-email-pbonzini@redhat.com> References: <1465319317-50519-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 06/13] scsi: megasas: null terminate bios version buffer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit While reading information via 'megasas_ctrl_get_info' routine, a local bios version buffer isn't null terminated. Add the terminating null byte to avoid any OOB access. Reported-by: Li Qiang Reviewed-by: Peter Maydell Signed-off-by: Prasad J Pandit Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index cc66d36..a9ffc32 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -773,6 +773,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) ptr = memory_region_get_ram_ptr(&pci_dev->rom); memcpy(biosver, ptr + 0x41, 31); + biosver[31] = 0; memcpy(info.image_component[1].name, "BIOS", 4); memcpy(info.image_component[1].version, biosver, strlen((const char *)biosver));