Re: [PATCH v6] platform/x86: hp-bioscfg: fix heap OOB in hp_enforce_single_line_input()
From: Ilpo Järvinen
Date: Wed Oct 21 2026 - 05:44:33 EST
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.