[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK7LNATPeS-cHtNGj_cfNypMkpgMYLa_Tc88Ce_3gUTEKqNkBQ@mail.gmail.com>
Date: Tue, 29 Jul 2025 22:41:04 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Suchit Karunakaran <suchitkarunakaran@...il.com>
Cc: nicolas.schier@...ux.dev, linux-kbuild@...r.kernel.org,
skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] kconfig/lxdialog: replace strcpy() with strncpy() in inputbox.c
On Mon, Jul 28, 2025 at 1:44 AM Suchit Karunakaran
<suchitkarunakaran@...il.com> wrote:
>
> strcpy() performs no bounds checking and can lead to buffer overflows if
> the input string exceeds the destination buffer size. This patch replaces
> it with strncpy(), and null terminates the input string.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@...il.com>
> ---
> scripts/kconfig/lxdialog/inputbox.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
> index 3c6e24b20f5b..5e4a131724f2 100644
> --- a/scripts/kconfig/lxdialog/inputbox.c
> +++ b/scripts/kconfig/lxdialog/inputbox.c
> @@ -39,8 +39,10 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
>
> if (!init)
> instr[0] = '\0';
> - else
> - strcpy(instr, init);
> + else {
> + strncpy(instr, init, sizeof(dialog_input_result) - 1);
> + instr[sizeof(dialog_input_result) - 1] = '\0';
> + }
Applied to linux-kbuild. Thanks.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists