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

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

 



2021-09-01 19:22 GMT+09:00, Dan Carpenter <dan.carpenter@xxxxxxxxxx>:
> 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.
Ah, Right, I will fix it on v2.
Thanks for your review!
>
>>
>>  	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