summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaket Dumbre <97769119+sacdintel@users.noreply.github.com>2023-03-22 15:36:51 -0700
committerGitHub <noreply@github.com>2023-03-22 15:36:51 -0700
commit920b610f7663c732fab41da4783f030bba8da40f (patch)
treecdc4e21b50aa1e7a7706be8ecd82ad75d35e6268
parent088c179a15baf4fb0c9ba186c43be93b78ca4df1 (diff)
parent7b23bdc37432f0b7fb6c3b6aa76debdcb7eb18c3 (diff)
downloadacpica-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.c11
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);
}