⬢ DragonFlyBSD Kernel Audit
DF-2372 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/acpica/Osd/OsdHardware.c
+++ b/sys/dev/acpica/Osd/OsdHardware.c
@@ -103,7 +103,8 @@
 
     *Value = pci_cfgregread(PciId->Bus, PciId->Device,
     				      PciId->Function, Register, bytes);
-    *Value &= (1 << (bytes * 8)) - 1;
+    /* (1 << 32) is UB on int (clangs to 0 on x86-64): use 64-bit math. */
+    *Value &= ((UINT64)1 << (bytes * 8)) - 1;
 
     return (AE_OK);
 }