Skip to contentSkip to conversation

ksmbd: Use struct_size() to improve get_file_alternate_info()

PATCH Applied Thorsten Blum 2 participants 2 messages Sep 27, 2024 – Sep 28, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ksmbd: Use struct_size() to improve get_file_alternate_info()

Use struct_size() to calculate the output buffer length.

---
 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
index 7121266daa02..b45e5b9ad967 100644
@@ -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,
Signature · 1 line
2.46.1