Skip to content

Commit

Permalink
ksmbd: Use struct_size() helper in ksmbd_negotiate_smb_dialect()
Browse files Browse the repository at this point in the history
Prefer struct_size() over open-coded versions.

Link: KSPP#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>
  • Loading branch information
GustavoARSilva authored and Steve French committed Jun 26, 2023
1 parent 7b7d709 commit 5211cc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/smb/server/smb_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static int ksmbd_negotiate_smb_dialect(void *buf)
if (smb2_neg_size > smb_buf_length)
goto err_out;

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

Expand Down

0 comments on commit 5211cc8

Please sign in to comment.