Skip to content

Commit 76d2ced

Browse files
reiserfs: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in direntry_uarea structure, and refactor the rest of the code, accordingly. Worth mentioning is that before these changes, the original implementation was returning two-too many bytes in function direntry_create_vi(): fs/reiserfs/item_ops.c:464: int size = sizeof(struct direntry_uarea); ... fs/reiserfs/item_ops.c-490- size += (dir_u->entry_count * sizeof(short)); ... fs/reiserfs/item_ops.c-517- return size; Link: KSPP#79 Link: KSPP#290 Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
1 parent 06c2afb commit 76d2ced

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

fs/reiserfs/fix_node.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,9 @@ static int get_virtual_node_size(struct super_block *sb, struct buffer_head *bh)
22522252

22532253
return sizeof(struct virtual_node) +
22542254
max(max_num_of_items * sizeof(struct virtual_item),
2255-
sizeof(struct virtual_item) + sizeof(struct direntry_uarea) +
2256-
(max_num_of_entries - 1) * sizeof(__u16));
2255+
sizeof(struct virtual_item) +
2256+
struct_size_t(struct direntry_uarea, entry_sizes,
2257+
max_num_of_entries));
22572258
}
22582259

22592260
/*

fs/reiserfs/reiserfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ struct virtual_node {
23732373
struct direntry_uarea {
23742374
int flags;
23752375
__u16 entry_count;
2376-
__u16 entry_sizes[1];
2376+
__u16 entry_sizes[];
23772377
} __attribute__ ((__packed__));
23782378

23792379
/***************************************************************************

0 commit comments

Comments
 (0)