From nobody Thu Dec 18 17:55:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608294099; cv=none; d=zohomail.com; s=zohoarc; b=dwyGkfyXYqzSdyjCFyMP7Wg8INS222cexAZ0srrCI780wDUsjxnN16XkdLK2sCNHhfrgzsDE2Axr2wm7fkIg3tDa+evQkYS5at3sIIjran5mCKmNZ6/rNHLRchuMirSW+DY21zEj1tLPd6cAl/5YLYCJNhM+EAmoDYEsaQK4rWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608294099; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0JcHwn3ghW6GtFPCujJbF4ZHfrin0ItMgun5PY9w4B0=; b=NBtInGoUBol1U/+iPWnwGc1K6jJtK4i4aYP65ihOD8XpduVUggavLEWpRKVhwr8ZdyrTkgeyOwzYS+Q2LB6gwFqtLgUZZV6UH4wjhRIzBCqBYXEVikAv3RHYrCYcdMPcZc7Txk4LifbndA/NxTayRVfXpODLronecb7YB5uvv04= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608294099540572.9943004309316; Fri, 18 Dec 2020 04:21:39 -0800 (PST) Received: from localhost ([::1]:44568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqElO-0006Cy-5w for importer@patchew.org; Fri, 18 Dec 2020 07:21:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqEbF-0001xj-QN for qemu-devel@nongnu.org; Fri, 18 Dec 2020 07:11:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqEb8-0001h6-8C for qemu-devel@nongnu.org; Fri, 18 Dec 2020 07:11:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-PsKnXg0SPcakET0DmsEtRw-1; Fri, 18 Dec 2020 07:10:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51A2A1934102; Fri, 18 Dec 2020 12:10:58 +0000 (UTC) Received: from merkur.fritz.box (ovpn-115-34.ams2.redhat.com [10.36.115.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C1E960C15; Fri, 18 Dec 2020 12:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608293461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0JcHwn3ghW6GtFPCujJbF4ZHfrin0ItMgun5PY9w4B0=; b=EP5WeZh86+iJdvkv/IpLVJA2/3JoV0hPcT80H0xs+/ONkZIsDSfvlCrm6iTlM6qHpqyQTh jIRtPdptA/jqL0Ak0lEgaCA3i2mpEXurQb7ZmSeOucIRE5XPCOpDNl4mRF4dakFwvBIa+W xCrtnPy4LnSBJpbb8lJGwRlE9QCNIxc= X-MC-Unique: PsKnXg0SPcakET0DmsEtRw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 09/17] block/vpc: Make vpc_open() read the full dynamic header Date: Fri, 18 Dec 2020 13:10:33 +0100 Message-Id: <20201218121041.299788-10-kwolf@redhat.com> In-Reply-To: <20201218121041.299788-1-kwolf@redhat.com> References: <20201218121041.299788-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Markus Armbruster The dynamic header's size is 1024 bytes. vpc_open() reads only the 512 bytes of the dynamic header into buf[]. Works, because it doesn't actually access the second half. However, a colleague told me that GCC 11 warns: ../block/vpc.c:358:51: error: array subscript 'struct VHDDynDiskHeader[= 0]' is partly outside array bounds of 'uint8_t[512]' [-Werror=3Darray-bound= s] Clean up to read the full header. Rename buf[] to dyndisk_header_buf[] while there. Signed-off-by: Markus Armbruster Message-Id: <20201217162003.1102738-2-armbru@redhat.com> Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- block/vpc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 1ab55f9287..2fcf3f6283 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -220,7 +220,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, QemuOpts *opts =3D NULL; Error *local_err =3D NULL; bool use_chs; - uint8_t buf[HEADER_SIZE]; + uint8_t dyndisk_header_buf[1024]; uint32_t checksum; uint64_t computed_size; uint64_t pagetable_size; @@ -340,14 +340,14 @@ static int vpc_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 if (disk_type =3D=3D VHD_DYNAMIC) { - ret =3D bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), buf, - HEADER_SIZE); + ret =3D bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), + dyndisk_header_buf, 1024); if (ret < 0) { error_setg(errp, "Error reading dynamic VHD header"); goto fail; } =20 - dyndisk_header =3D (VHDDynDiskHeader *) buf; + dyndisk_header =3D (VHDDynDiskHeader *)dyndisk_header_buf; =20 if (strncmp(dyndisk_header->magic, "cxsparse", 8)) { error_setg(errp, "Invalid header magic"); --=20 2.29.2