Re: [PATCH 3/4] ksmbd: add validation for ndr read/write functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux