Re: [PATCH] firmware: tegra: fix strncpy()/strncat() confusion

From: Arnd Bergmann
Date: Mon Oct 26 2020 - 12:41:09 EST


On Mon, Oct 26, 2020 at 5:35 PM Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:

> > diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
> > index c1bbba9ee93a..9ec20ddc9a6b 100644
> > --- a/drivers/firmware/tegra/bpmp-debugfs.c
> > +++ b/drivers/firmware/tegra/bpmp-debugfs.c
> > @@ -412,16 +412,12 @@ static int bpmp_populate_debugfs_inband(struct tegra_bpmp *bpmp,
> > goto out;
> > }
> >
> > - len = strlen(ppath) + strlen(name) + 1;
> > + len = snprintf("%s%s/", pathlen, ppath, name);
>
> Didn't you get any warnings with this? It should be
> len = snprintf(pathbuf, pathlen, "%s%s/", ppath, name);
> right?
>

Eek, I did get a warning about a different issue in that one-line change and
fixed it up in the wrong way without testing again. Sorry about that.

I'll retest and resend.

Arnd