Skip to content

Commit

Permalink
ACPI_PCI_ROUTING_TABLE: Replace fixed-size array with flex array member
Browse files Browse the repository at this point in the history
The "Source" array is actually a dynamically sized array, but it
is defined as a fixed-size 4 byte array. This results in tripping
both compile-time and run-time bounds checkers (e.g. via either
__builtin_object_size() or -fsanitize=bounds).

To retain the padding, create a union with an unused Pad variable of
size 4, and redefine Source as a proper flexible array member.
  • Loading branch information
kees committed Nov 18, 2022
1 parent 8a84431 commit b1c7901
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/include/acrestyp.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,10 @@ typedef struct acpi_pci_routing_table
UINT32 Pin;
UINT64 Address; /* here for 64-bit alignment */
UINT32 SourceIndex;
char Source[4]; /* pad to 64 bits so sizeof() works in all cases */

union {
char Pad[4]; /* pad to 64 bits so sizeof() works in all cases */
ACPI_FLEX_ARRAY(char, Source);
};
} ACPI_PCI_ROUTING_TABLE;

#endif /* __ACRESTYP_H__ */

0 comments on commit b1c7901

Please sign in to comment.