lkml.org 
[lkml]   [2020]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RESEND 04/10] crypto: hisilicon/zip - replace 'sprintf' with 'scnprintf'
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,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2020-09-04 09:40    [W:0.065 / U:2.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site