Skip to content

Commit

Permalink
gcc-plugins: randstruct: Update code comment in relayout_struct()
Browse files Browse the repository at this point in the history
Update code comment to clarify that the only element whose layout is
not randomized is a proper C99 flexible-array member. This update is
complementary to commit 1ee6035 ("gcc-plugins: randstruct: Only
warn about true flexible arrays")

Signed-off-by: "Gustavo A. R. Silva" <[email protected]>
Link: https://lore.kernel.org/r/ZWJr2MWDjXLHE8ap@work
Fixes: 1ee6035 ("gcc-plugins: randstruct: Only warn about true flexible arrays")
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
GustavoARSilva authored and kees committed Nov 28, 2023
1 parent 4e86f32 commit d71f223
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions scripts/gcc-plugins/randomize_layout_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ static int relayout_struct(tree type)

/*
* enforce that we don't randomize the layout of the last
* element of a struct if it's a 0 or 1-length array
* or a proper flexible array
* element of a struct if it's a proper flexible array
*/
if (is_flexible_array(newtree[num_fields - 1])) {
has_flexarray = true;
Expand Down

0 comments on commit d71f223

Please sign in to comment.