ksmbd: Use struct_size() to improve get_file_alternate_info()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 27 Sep 2024 14:36:42 +0000 (16:36 +0200)
committerSteve French <stfrench@microsoft.com>
Tue, 1 Oct 2024 19:50:51 +0000 (14:50 -0500)
Use struct_size() to calculate the output buffer length.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb2pdu.c

index 7460089c186f08241b0b2c823e99578fdff7e01e..f28346fad89402caa75a8cfa326e621b008b9e85 100644 (file)
@@ -4883,7 +4883,7 @@ static void get_file_alternate_info(struct ksmbd_work *work,
        spin_unlock(&dentry->d_lock);
        file_info->FileNameLength = cpu_to_le32(conv_len);
        rsp->OutputBufferLength =
-               cpu_to_le32(sizeof(struct smb2_file_alt_name_info) + conv_len);
+               cpu_to_le32(struct_size(file_info, FileName, conv_len));
 }
 
 static int get_file_stream_info(struct ksmbd_work *work,