One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element arrays with flexible-array members in multiple structs in fs/ksmbd/smb_common.h and one in fs/ksmbd/smb2pdu.h. Important to mention is that doing a build before/after this patch results in no binary output differences. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1].
Unified · Split
| @@ -3438,7 +3438,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, · 3437 unmodified lines | ||
| 3438 | 3438 | goto free_conv_name; |
| 3439 | 3439 | } |
| 3440 | 3440 | |
| 3441 | − struct_sz = readdir_info_level_struct_sz(info_level) - 1 + conv_len; | |
| 3441 | + struct_sz = readdir_info_level_struct_sz(info_level) + conv_len; | |
| 3442 | 3442 | next_entry_offset = ALIGN(struct_sz, KSMBD_DIR_INFO_ALIGNMENT); |
| 3443 | 3443 | d_info->last_entry_off_align = next_entry_offset - struct_sz; |
| 3444 | 3444 | |
| @@ -3690,7 +3690,7 @@ static int reserve_populate_dentry(struct ksmbd_dir_info *d_info, · 245 unmodified lines | ||
| 3690 | 3690 | return -EOPNOTSUPP; |
| 3691 | 3691 | |
| 3692 | 3692 | conv_len = (d_info->name_len + 1) * 2; |
| 3693 | − next_entry_offset = ALIGN(struct_sz - 1 + conv_len, | |
| 3693 | + next_entry_offset = ALIGN(struct_sz + conv_len, | |
| 3694 | 3694 | KSMBD_DIR_INFO_ALIGNMENT); |
| 3695 | 3695 | |
| 3696 | 3696 | if (next_entry_offset > d_info->out_buf_len) { |
| @@ -443,7 +443,7 @@ struct smb2_posix_info { · 442 unmodified lines | ||
| 443 | 443 | /* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ |
| 444 | 444 | u8 SidBuffer[32]; |
| 445 | 445 | __le32 name_len; |
| 446 | − u8 name[1]; | |
| 446 | + u8 name[]; | |
| 447 | 447 | /* |
| 448 | 448 | * var sized owner SID |
| 449 | 449 | * var sized group SID |
| @@ -277,14 +277,14 @@ struct file_directory_info { · 276 unmodified lines | ||
| 277 | 277 | __le64 AllocationSize; |
| 278 | 278 | __le32 ExtFileAttributes; |
| 279 | 279 | __le32 FileNameLength; |
| 280 | − char FileName[1]; | |
| 280 | + char FileName[]; | |
| 281 | 281 | } __packed; /* level 0x101 FF resp data */ |
| 282 | 282 | |
| 283 | 283 | struct file_names_info { |
| 284 | 284 | __le32 NextEntryOffset; |
| 285 | 285 | __u32 FileIndex; |
| 286 | 286 | __le32 FileNameLength; |
| 287 | − char FileName[1]; | |
| 287 | + char FileName[]; | |
| 288 | 288 | } __packed; /* level 0xc FF resp data */ |
| 289 | 289 | |
| 290 | 290 | struct file_full_directory_info { |
| @@ -299,7 +299,7 @@ struct file_full_directory_info { · 8 unmodified lines | ||
| 299 | 299 | __le32 ExtFileAttributes; |
| 300 | 300 | __le32 FileNameLength; |
| 301 | 301 | __le32 EaSize; |
| 302 | − char FileName[1]; | |
| 302 | + char FileName[]; | |
| 303 | 303 | } __packed; /* level 0x102 FF resp */ |
| 304 | 304 | |
| 305 | 305 | struct file_both_directory_info { |
| @@ -317,7 +317,7 @@ struct file_both_directory_info { · 11 unmodified lines | ||
| 317 | 317 | __u8 ShortNameLength; |
| 318 | 318 | __u8 Reserved; |
| 319 | 319 | __u8 ShortName[24]; |
| 320 | − char FileName[1]; | |
| 320 | + char FileName[]; | |
| 321 | 321 | } __packed; /* level 0x104 FFrsp data */ |
| 322 | 322 | |
| 323 | 323 | struct file_id_both_directory_info { |
| @@ -337,7 +337,7 @@ struct file_id_both_directory_info { · 13 unmodified lines | ||
| 337 | 337 | __u8 ShortName[24]; |
| 338 | 338 | __le16 Reserved2; |
| 339 | 339 | __le64 UniqueId; |
| 340 | − char FileName[1]; | |
| 340 | + char FileName[]; | |
| 341 | 341 | } __packed; |
| 342 | 342 | |
| 343 | 343 | struct file_id_full_dir_info { |
| @@ -354,7 +354,7 @@ struct file_id_full_dir_info { · 10 unmodified lines | ||
| 354 | 354 | __le32 EaSize; /* EA size */ |
| 355 | 355 | __le32 Reserved; |
| 356 | 356 | __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ |
| 357 | − char FileName[1]; | |
| 357 | + char FileName[]; | |
| 358 | 358 | } __packed; /* level 0x105 FF rsp data */ |
| 359 | 359 | |
| 360 | 360 | struct smb_version_values { |