History

ksmbd: replace one-element arrays with flexible-array members

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].

Gustavo A. R. Silva committed 3 years ago

Commit d272e011 parent d6621983 files · +9 −9Browse files

Unified · Split

3 files
  1. fs/ksmbd/smb2pdu.c +2 −2
  2. fs/ksmbd/smb2pdu.h +1 −1
  3. fs/ksmbd/smb_common.h +6 −6
fs/ksmbd/smb2pdu.c+2−2
@@ -3438,7 +3438,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level, · 3437 unmodified lines
3438 goto free_conv_name;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 next_entry_offset = ALIGN(struct_sz, KSMBD_DIR_INFO_ALIGNMENT);3442 next_entry_offset = ALIGN(struct_sz, KSMBD_DIR_INFO_ALIGNMENT);
3443 d_info->last_entry_off_align = next_entry_offset - struct_sz;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 return -EOPNOTSUPP;3690 return -EOPNOTSUPP;
3691 3691
3692 conv_len = (d_info->name_len + 1) * 2;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 KSMBD_DIR_INFO_ALIGNMENT);3694 KSMBD_DIR_INFO_ALIGNMENT);
3695 3695
3696 if (next_entry_offset > d_info->out_buf_len) {3696 if (next_entry_offset > d_info->out_buf_len) {
fs/ksmbd/smb2pdu.h+1−1
@@ -443,7 +443,7 @@ struct smb2_posix_info { · 442 unmodified lines
443 /* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */443 /* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */
444 u8 SidBuffer[32];444 u8 SidBuffer[32];
445 __le32 name_len;445 __le32 name_len;
446 u8 name[1];446 u8 name[];
447 /*447 /*
448 * var sized owner SID448 * var sized owner SID
449 * var sized group SID449 * var sized group SID
fs/ksmbd/smb_common.h+6−6
@@ -277,14 +277,14 @@ struct file_directory_info { · 276 unmodified lines
277 __le64 AllocationSize;277 __le64 AllocationSize;
278 __le32 ExtFileAttributes;278 __le32 ExtFileAttributes;
279 __le32 FileNameLength;279 __le32 FileNameLength;
280 char FileName[1];280 char FileName[];
281} __packed; /* level 0x101 FF resp data */281} __packed; /* level 0x101 FF resp data */
282 282
283struct file_names_info {283struct file_names_info {
284 __le32 NextEntryOffset;284 __le32 NextEntryOffset;
285 __u32 FileIndex;285 __u32 FileIndex;
286 __le32 FileNameLength;286 __le32 FileNameLength;
287 char FileName[1];287 char FileName[];
288} __packed; /* level 0xc FF resp data */288} __packed; /* level 0xc FF resp data */
289 289
290struct file_full_directory_info {290struct file_full_directory_info {
@@ -299,7 +299,7 @@ struct file_full_directory_info { · 8 unmodified lines
299 __le32 ExtFileAttributes;299 __le32 ExtFileAttributes;
300 __le32 FileNameLength;300 __le32 FileNameLength;
301 __le32 EaSize;301 __le32 EaSize;
302 char FileName[1];302 char FileName[];
303} __packed; /* level 0x102 FF resp */303} __packed; /* level 0x102 FF resp */
304 304
305struct file_both_directory_info {305struct file_both_directory_info {
@@ -317,7 +317,7 @@ struct file_both_directory_info { · 11 unmodified lines
317 __u8 ShortNameLength;317 __u8 ShortNameLength;
318 __u8 Reserved;318 __u8 Reserved;
319 __u8 ShortName[24];319 __u8 ShortName[24];
320 char FileName[1];320 char FileName[];
321} __packed; /* level 0x104 FFrsp data */321} __packed; /* level 0x104 FFrsp data */
322 322
323struct file_id_both_directory_info {323struct file_id_both_directory_info {
@@ -337,7 +337,7 @@ struct file_id_both_directory_info { · 13 unmodified lines
337 __u8 ShortName[24];337 __u8 ShortName[24];
338 __le16 Reserved2;338 __le16 Reserved2;
339 __le64 UniqueId;339 __le64 UniqueId;
340 char FileName[1];340 char FileName[];
341} __packed;341} __packed;
342 342
343struct file_id_full_dir_info {343struct file_id_full_dir_info {
@@ -354,7 +354,7 @@ struct file_id_full_dir_info { · 10 unmodified lines
354 __le32 EaSize; /* EA size */354 __le32 EaSize; /* EA size */
355 __le32 Reserved;355 __le32 Reserved;
356 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/356 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
357 char FileName[1];357 char FileName[];
358} __packed; /* level 0x105 FF rsp data */358} __packed; /* level 0x105 FF rsp data */
359 359
360struct smb_version_values {360struct smb_version_values {