Skip to content

Commit

Permalink
ksmbd: fix error code in ndr_read_int32()
Browse files Browse the repository at this point in the history
This is a failure path and it should return -EINVAL instead of success.
Otherwise it could result in the caller using uninitialized memory.

Fixes: 303fff2 ("ksmbd: add validation for ndr read/write functions")
Cc: stable@vger.kernel.org # v5.15
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Dan Carpenter authored and Steve French committed Dec 16, 2021
1 parent 2585cf9 commit ef39946
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ksmbd/ndr.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static int ndr_read_int16(struct ndr *n, __u16 *value)
static int ndr_read_int32(struct ndr *n, __u32 *value)
{
if (n->offset + sizeof(__u32) > n->length)
return 0;
return -EINVAL;

if (value)
*value = le32_to_cpu(*(__le32 *)ndr_get_field(n));
Expand Down

0 comments on commit ef39946

Please sign in to comment.