[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240927143642.2086-2-thorsten.blum@linux.dev>
Date: Fri, 27 Sep 2024 16:36:42 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Namjae Jeon <linkinjeon@...nel.org>,
	Steve French <sfrench@...ba.org>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Tom Talpey <tom@...pey.com>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
	linux-cifs@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] ksmbd: Use struct_size() to improve get_file_alternate_info()
Use struct_size() to calculate the output buffer length.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
---
 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 7121266daa02..b45e5b9ad967 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4887,7 +4887,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,
-- 
2.46.1
Powered by blists - more mailing lists