Re: [PATCH v6] platform/x86: hp-bioscfg: fix heap OOB in hp_enforce_single_line_input()
From: Muhammad Bilal
Date: Sat Oct 24 2026 - 14:06:23 EST
Hi Andy, Ilpo,
Thanks for the review. I switched to strnchrnul() as Andy suggested and
posted v7:
https://lore.kernel.org/all/20261024172641.19424-1-meatuni001@xxxxxxxxx/
Thanks
Muhammad
On Wed, Oct 21, 2026 at 2:41 PM Ilpo Järvinen
<ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, 21 Oct 2026, Ilpo Järvinen wrote:
>
> > On Wed, 21 Oct 2026, Muhammad Bilal wrote:
> >
> > > Hi Ilpo,
> > >
> > > > Why use n variant?
> > > strnlen() keeps the read within count, which is the size of buf as far
> > > as this helper knows, so it does not depend on the caller NUL
> > > terminating the buffer. Both current callers pass a kstrdup() copy, so
> > > strlen() works too. I can switch to it in v7 if you prefer.
> >
> > As the contract here is the input must be a string, I don't see any need
> > to limit the length with n variant so I do prefer strlen(). Also, we know
> > that it should not be longer than count anyway.
>
> I only now notice Andy's comments which seem better suggestion in general.
>
> --
> i.