linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Subject: Re: [PATCH 3/4] ksmbd: add validation for ndr read/write functions
Date: Wed, 1 Sep 2021 13:22:40 +0300	[thread overview]
Message-ID: <20210901102240.GA2129@kadam> (raw)
In-Reply-To: <20210901004537.45511-3-linkinjeon@kernel.org>

On Wed, Sep 01, 2021 at 09:45:36AM +0900, Namjae Jeon wrote:
>  int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da)
>  {
> -	char *hex_attr;
> -	int version2;
> -
> -	hex_attr = kzalloc(n->length, GFP_KERNEL);
> -	if (!hex_attr)
> -		return -ENOMEM;
> +	char hex_attr[12];
> +	unsigned int version2, ret;

"ret" should be int.  It doesn't affect runtime but for correctness it
should be int.

>  
>  	n->offset = 0;
> -	ndr_read_string(n, hex_attr, n->length);
> -	kfree(hex_attr);
> -	da->version = ndr_read_int16(n);
> +	ret = ndr_read_string(n, hex_attr, sizeof(hex_attr));
> +	if (ret)
> +		return ret;

regards,
dan carpenter


  reply	other threads:[~2021-09-01 10:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01  0:45 [PATCH 1/4] ksmbd: Reduce error log 'speed is unknown' to debug Namjae Jeon
2021-09-01  0:45 ` [PATCH 2/4] ksmbd: smbd: fix dma mapping error in smb_direct_post_send_data Namjae Jeon
2021-09-01  0:45 ` [PATCH 3/4] ksmbd: add validation for ndr read/write functions Namjae Jeon
2021-09-01 10:22   ` Dan Carpenter [this message]
2021-09-01 12:28     ` Namjae Jeon
2021-09-01  0:45 ` [PATCH 4/4] ksmbd: remove unused ksmbd_file_table_flush function Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210901102240.GA2129@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --subject='Re: [PATCH 3/4] ksmbd: add validation for ndr read/write functions' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).