Re: [PATCH] ACPI: OSI: refactor deprecated strncpy

From: Rafael J. Wysocki
Date: Thu Sep 21 2023 - 16:16:42 EST


On Fri, Sep 15, 2023 at 5:16 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
>
> On Mon, Sep 11, 2023 at 08:36:44PM +0000, Justin Stitt wrote:
> > `strncpy` is deprecated for use on NUL-terminated destination strings [1].
> >
> > We know `osi->string` is a NUL-terminated string due to its eventual use
> > in `acpi_install_interface()` and `acpi_remove_interface()` which expect
> > a `acpi_string` which has been specifically typedef'd as:
> > | typedef char *acpi_string; /* Null terminated ASCII string */
> >
> > ... and which also has other string functions used on it like `strlen`.
> > Furthermore, padding is not needed in this instance either.
>
> Following the callers, I agree, this doesn't need %NUL padding -- it's
> always processed as a regular C string.
>
> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

Applied as 6.7 material, thanks!