diff options
author | Saket Dumbre <97769119+sacdintel@users.noreply.github.com> | 2023-03-22 15:36:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 15:36:51 -0700 |
commit | 920b610f7663c732fab41da4783f030bba8da40f (patch) | |
tree | cdc4e21b50aa1e7a7706be8ecd82ad75d35e6268 | |
parent | 088c179a15baf4fb0c9ba186c43be93b78ca4df1 (diff) | |
parent | 7b23bdc37432f0b7fb6c3b6aa76debdcb7eb18c3 (diff) | |
download | acpica-920b610f7663c732fab41da4783f030bba8da40f.tar.gz |
Merge pull request #850 from tamird/ub-member-access-within-misaligned-address-two
Avoid undefined behavior: member access within misaligned address
-rw-r--r-- | source/components/utilities/utresrc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c index 7898e9929..f47b29246 100644 --- a/source/components/utilities/utresrc.c +++ b/source/components/utilities/utresrc.c @@ -532,16 +532,21 @@ AcpiUtValidateResource ( AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml); if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS) { + /* Avoid undefined behavior: member access within misaligned address */ + + AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus; + memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus)); + /* Validate the BusType field */ - if ((AmlResource->CommonSerialBus.Type == 0) || - (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)) + if ((CommonSerialBus.Type == 0) || + (CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)) { if (WalkState) { ACPI_ERROR ((AE_INFO, "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", - AmlResource->CommonSerialBus.Type)); + CommonSerialBus.Type)); } return (AE_AML_INVALID_RESOURCE_TYPE); } |