summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaket Dumbre <97769119+sacdintel@users.noreply.github.com>2023-03-22 15:36:29 -0700
committerGitHub <noreply@github.com>2023-03-22 15:36:29 -0700
commit088c179a15baf4fb0c9ba186c43be93b78ca4df1 (patch)
tree3d46d29b20d1a75e1e8c0081f0a1c008d6e7f37e
parent2073bcb8a132e2ee16e98bbc0c414f32e5d72275 (diff)
parent60cbb20c009fd67e7b973d67b5dcb4a7b12681d9 (diff)
downloadacpica-088c179a15baf4fb0c9ba186c43be93b78ca4df1.tar.gz
Merge pull request #852 from tamird/ub-member-access-within-misaligned-address-three
Avoid undefined behavior: member access within misaligned address
-rw-r--r--source/components/resources/rscalc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/source/components/resources/rscalc.c b/source/components/resources/rscalc.c
index 623364b10..55694f1ec 100644
--- a/source/components/resources/rscalc.c
+++ b/source/components/resources/rscalc.c
@@ -740,14 +740,19 @@ AcpiRsGetListLength (
}
break;
- case ACPI_RESOURCE_NAME_SERIAL_BUS:
+ case ACPI_RESOURCE_NAME_SERIAL_BUS: {
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
- AmlResource->CommonSerialBus.Type];
+ CommonSerialBus.Type];
ExtraStructBytes +=
- AmlResource->CommonSerialBus.ResourceLength -
+ CommonSerialBus.ResourceLength -
MinimumAmlResourceLength;
break;
+ }
case ACPI_RESOURCE_NAME_PIN_CONFIG:
@@ -816,8 +821,13 @@ AcpiRsGetListLength (
if (AcpiUtGetResourceType (AmlBuffer) ==
ACPI_RESOURCE_NAME_SERIAL_BUS)
{
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
+
BufferSize = AcpiGbl_ResourceStructSerialBusSizes[
- AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
+ CommonSerialBus.Type] + ExtraStructBytes;
}
else
{