[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit |
Date: |
Fri, 3 Sep 2021 19:44:50 +0200 |
acpi_data_len() returns an unsigned type, which might be bigger
than 32-bit (although it is unlikely such value is returned).
Hold the returned value in an 'unsigned' type to avoid unlikely
size truncation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/virt-acpi-build.c | 2 +-
hw/i386/acpi-build.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 037cc1fd82c..95543d43e2a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -885,7 +885,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables
*tables)
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
{
- uint32_t size = acpi_data_len(data);
+ unsigned size = acpi_data_len(data);
/* Make sure RAM size is correct - in case it got changed
* e.g. by migration */
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a33ac8b91e1..aa269914b49 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2660,7 +2660,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState
*machine)
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
{
- uint32_t size = acpi_data_len(data);
+ unsigned size = acpi_data_len(data);
/* Make sure RAM size is correct - in case it got changed e.g. by
migration */
memory_region_ram_resize(mr, size, &error_abort);
@@ -2783,7 +2783,7 @@ void acpi_setup(void)
* Though RSDP is small, its contents isn't immutable, so
* we'll update it along with the rest of tables on guest access.
*/
- uint32_t rsdp_size = acpi_data_len(tables.rsdp);
+ unsigned rsdp_size = acpi_data_len(tables.rsdp);
build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size);
fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE,
--
2.31.1
- Re: [PATCH v3 02/28] glib-compat: Introduce g_memdup2() wrapper, (continued)
- [PATCH v3 03/28] qapi: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 04/28] accel/tcg: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 05/28] block/qcow2-bitmap: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 06/28] softmmu: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 07/28] hw/9pfs: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit,
Philippe Mathieu-Daudé <=
- [PATCH v3 09/28] hw/acpi: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 10/28] hw/core/machine: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 11/28] hw/hppa/machine: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 12/28] hw/i386/multiboot: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 13/28] hw/net/eepro100: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 14/28] hw/nvram/fw_cfg: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 15/28] hw/scsi/mptsas: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 16/28] hw/ppc/spapr_pci: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH v3 17/28] hw/rdma: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2021/09/03