diff options
author | Kees Cook <kees@outflux.net> | 2023-02-23 17:12:21 -0800 |
---|---|---|
committer | Kees Cook <kees@outflux.net> | 2023-03-02 11:03:42 -0800 |
commit | 44f1af0664599e87bebc3a1260692baa27b2f264 (patch) | |
tree | 5fe751c1d1fdcf3f7d5259700995fc083f274aa6 | |
parent | 8c9bd5d151f77767b2fd937911848b7159dc8ee9 (diff) | |
download | acpica-44f1af0664599e87bebc3a1260692baa27b2f264.tar.gz |
actbl2: Replace 1-element arrays with flexible arrays
Similar to commit 7ba2f3d91a32 ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
The sizeof() uses with ACPI_NFIT_FLUSH_ADDRESS and ACPI_NFIT_SMBIOS have
been adjusted to drop the open-coded subtraction of the trailing single
element. The result is no binary differences in .text nor .data sections.
-rw-r--r-- | source/common/dmtbdump2.c | 6 | ||||
-rw-r--r-- | source/include/actbl2.h | 16 |
2 files changed, 11 insertions, 11 deletions
diff --git a/source/common/dmtbdump2.c b/source/common/dmtbdump2.c index 353979e8f..7216f877f 100644 --- a/source/common/dmtbdump2.c +++ b/source/common/dmtbdump2.c @@ -1538,7 +1538,7 @@ AcpiDmDumpNfit ( /* Has a variable number of 64-bit addresses at the end */ InfoTable = AcpiDmTableInfoNfit6; - FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS) - sizeof (UINT64); + FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS); break; case ACPI_NFIT_TYPE_CAPABILITIES: /* ACPI 6.0A */ @@ -1592,12 +1592,12 @@ AcpiDmDumpNfit ( case ACPI_NFIT_TYPE_SMBIOS: Length = Subtable->Length - - sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8); + sizeof (ACPI_NFIT_SMBIOS); if (Length) { Status = AcpiDmDumpTable (Table->Length, - sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8), + sizeof (ACPI_NFIT_SMBIOS), SmbiosInfo, Length, AcpiDmTableInfoNfit3a); if (ACPI_FAILURE (Status)) diff --git a/source/include/actbl2.h b/source/include/actbl2.h index 6dc2efd0c..6f13261a6 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -572,7 +572,7 @@ typedef struct acpi_iort_node UINT32 Identifier; UINT32 MappingCount; UINT32 MappingOffset; - char NodeData[1]; + char NodeData[]; } ACPI_IORT_NODE; @@ -638,7 +638,7 @@ typedef struct acpi_iort_memory_access typedef struct acpi_iort_its_group { UINT32 ItsCount; - UINT32 Identifiers[1]; /* GIC ITS identifier array */ + UINT32 Identifiers[]; /* GIC ITS identifier array */ } ACPI_IORT_ITS_GROUP; @@ -648,7 +648,7 @@ typedef struct acpi_iort_named_component UINT32 NodeFlags; UINT64 MemoryProperties; /* Memory access properties */ UINT8 MemoryAddressLimit; /* Memory address size limit */ - char DeviceName[1]; /* Path of namespace object */ + char DeviceName[]; /* Path of namespace object */ } ACPI_IORT_NAMED_COMPONENT; @@ -664,7 +664,7 @@ typedef struct acpi_iort_root_complex UINT32 PciSegmentNumber; UINT8 MemoryAddressLimit; /* Memory address size limit */ UINT16 PasidCapabilities; /* PASID Capabilities */ - UINT8 Reserved[1]; /* Reserved, must be zero */ + UINT8 Reserved[]; /* Reserved, must be zero */ } ACPI_IORT_ROOT_COMPLEX; @@ -688,7 +688,7 @@ typedef struct acpi_iort_smmu UINT32 ContextInterruptOffset; UINT32 PmuInterruptCount; UINT32 PmuInterruptOffset; - UINT64 Interrupts[1]; /* Interrupt array */ + UINT64 Interrupts[]; /* Interrupt array */ } ACPI_IORT_SMMU; @@ -1240,7 +1240,7 @@ typedef struct acpi_madt_local_sapic UINT8 Reserved[3]; /* Reserved, must be zero */ UINT32 LapicFlags; UINT32 Uid; /* Numeric UID - ACPI 3.0 */ - char UidString[1]; /* String UID - ACPI 3.0 */ + char UidString[]; /* String UID - ACPI 3.0 */ } ACPI_MADT_LOCAL_SAPIC; @@ -2056,7 +2056,7 @@ typedef struct acpi_nfit_smbios { ACPI_NFIT_HEADER Header; UINT32 Reserved; /* Reserved, must be zero */ - UINT8 Data[1]; /* Variable length */ + UINT8 Data[]; /* Variable length */ } ACPI_NFIT_SMBIOS; @@ -2122,7 +2122,7 @@ typedef struct acpi_nfit_flush_address UINT32 DeviceHandle; UINT16 HintCount; UINT8 Reserved[6]; /* Reserved, must be zero */ - UINT64 HintAddress[1]; /* Variable length */ + UINT64 HintAddress[]; /* Variable length */ } ACPI_NFIT_FLUSH_ADDRESS; |