提交 ef399469 编写于 作者: D Dan Carpenter 提交者: Steve French

ksmbd: fix error code in ndr_read_int32()

This is a failure path and it should return -EINVAL instead of success.
Otherwise it could result in the caller using uninitialized memory.

Fixes: 303fff2b ("ksmbd: add validation for ndr read/write functions")
Cc: stable@vger.kernel.org # v5.15
Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 2585cf9d
...@@ -148,7 +148,7 @@ static int ndr_read_int16(struct ndr *n, __u16 *value) ...@@ -148,7 +148,7 @@ static int ndr_read_int16(struct ndr *n, __u16 *value)
static int ndr_read_int32(struct ndr *n, __u32 *value) static int ndr_read_int32(struct ndr *n, __u32 *value)
{ {
if (n->offset + sizeof(__u32) > n->length) if (n->offset + sizeof(__u32) > n->length)
return 0; return -EINVAL;
if (value) if (value)
*value = le32_to_cpu(*(__le32 *)ndr_get_field(n)); *value = le32_to_cpu(*(__le32 *)ndr_get_field(n));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册