From: "shenyang (M)" <shenyang39@huawei.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Laight <David.Laight@ACULAB.COM>,
"davem@davemloft.net" <davem@davemloft.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"xuzaibo@huawei.com" <xuzaibo@huawei.com>,
"wangzhou1@hisilicon.com" <wangzhou1@hisilicon.com>
Subject: Re: [PATCH RESEND 04/10] crypto: hisilicon/zip - replace 'sprintf' with 'scnprintf'
Date: Fri, 4 Sep 2020 16:43:14 +0800 [thread overview]
Message-ID: <4af18f59-9e91-7a16-bb6b-1a66a9056c10@huawei.com> (raw)
In-Reply-To: <20200904074004.GA24815@gondor.apana.org.au>
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
next prev parent reply other threads:[~2020-09-04 8:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 3:11 [PATCH RESEND 00/10] crypto: hisilicon/zip - misc clean up Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 01/10] crypto: hisilicon/zip - remove some useless parameters Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 02/10] crypto: hisilicon/zip - unify naming style for functions and macros Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 03/10] crypto: hisilicon/zip - modify debugfs interface parameters Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 04/10] crypto: hisilicon/zip - replace 'sprintf' with 'scnprintf' Yang Shen
2020-08-24 8:29 ` David Laight
2020-08-26 8:56 ` shenyang (M)
2020-09-04 7:40 ` Herbert Xu
2020-09-04 8:43 ` shenyang (M) [this message]
2020-08-24 3:11 ` [PATCH RESEND 05/10] crypto: hisilicon/zip - use a enum parameter instead of some macros Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 06/10] crypto: hisilicon/zip - add print for error branch Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 07/10] crypto: hisilicon/zip - fix static check warning Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 08/10] crypto: hisilicon/zip - move some private macros from 'zip.h' to 'zip_crypto.c' Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 09/10] crypto: hisilicon/zip - supplement some comments Yang Shen
2020-08-24 3:11 ` [PATCH RESEND 10/10] crypto: hisilicon/zip - fix some coding styles Yang Shen
2020-09-02 9:36 ` [PATCH RESEND 00/10] crypto: hisilicon/zip - misc clean up shenyang (M)
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=4af18f59-9e91-7a16-bb6b-1a66a9056c10@huawei.com \
--to=shenyang39@huawei.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangzhou1@hisilicon.com \
--cc=xuzaibo@huawei.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®