Skip to content

Commit 5211cc8

Browse files
GustavoARSilvasmfrench
authored andcommitted
ksmbd: Use struct_size() helper in ksmbd_negotiate_smb_dialect()
Prefer struct_size() over open-coded versions. Link: KSPP/linux#160 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 7b7d709 commit 5211cc8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/smb/server/smb_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int ksmbd_negotiate_smb_dialect(void *buf)
266266
if (smb2_neg_size > smb_buf_length)
267267
goto err_out;
268268

269-
if (smb2_neg_size + le16_to_cpu(req->DialectCount) * sizeof(__le16) >
269+
if (struct_size(req, Dialects, le16_to_cpu(req->DialectCount)) >
270270
smb_buf_length)
271271
goto err_out;
272272

0 commit comments

Comments
 (0)