lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4af18f59-9e91-7a16-bb6b-1a66a9056c10@huawei.com>
Date:   Fri, 4 Sep 2020 16:43:14 +0800
From:   "shenyang (M)" <shenyang39@...wei.com>
To:     Herbert Xu <herbert@...dor.apana.org.au>
CC:     David Laight <David.Laight@...LAB.COM>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "xuzaibo@...wei.com" <xuzaibo@...wei.com>,
        "wangzhou1@...ilicon.com" <wangzhou1@...ilicon.com>
Subject: Re: [PATCH RESEND 04/10] crypto: hisilicon/zip - replace 'sprintf'
 with 'scnprintf'



On 2020/9/4 15:40, Herbert Xu wrote:
> On Wed, Aug 26, 2020 at 04:56:40PM +0800, shenyang (M) wrote:
>>
>>>> @@ -514,13 +514,16 @@ static int hisi_zip_core_debug_init(struct hisi_qm *qm)
>>>>  	struct debugfs_regset32 *regset;
>>>>  	struct dentry *tmp_d;
>>>>  	char buf[HZIP_BUF_SIZE];
>>>> -	int i;
>>>> +	int i, ret;
>>>>
>>>>  	for (i = 0; i < HZIP_CORE_NUM; i++) {
>>>>  		if (i < HZIP_COMP_CORE_NUM)
>>>> -			sprintf(buf, "comp_core%d", i);
>>>> +			ret = scnprintf(buf, HZIP_BUF_SIZE, "comp_core%d", i);
>>>>  		else
>>>> -			sprintf(buf, "decomp_core%d", i - HZIP_COMP_CORE_NUM);
>>>> +			ret = scnprintf(buf, HZIP_BUF_SIZE, "decomp_core%d",
>>>> +					i - HZIP_COMP_CORE_NUM);
>>>> +		if (!ret)
>>>> +			return -ENOMEM;
>>>
>>> and that is just so wrong - did you even try to test
>>> the 'buffer too small' code path?
>>
>> Do you means the check is unnecessary?
>
> No he's saying that your patch does the wrong thing when the string
> is truncated.
>
> Also ENOMEM is a strange error for that case.
>
> Cheers,
>

Here 'HZIP_BUF_SIZE' is 22, so the buf is enough for the string.

The check for the return is really unnecessary, I will remove it in the
next version.

Thanks,
Yang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ