]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c
authorSuchit Karunakaran <suchitkarunakaran@gmail.com>
Sun, 27 Jul 2025 16:44:33 +0000 (22:14 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:30 +0000 (18:41 +0200)
[ Upstream commit 5ac726653a1029a2eccba93bbe59e01fc9725828 ]

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@gmail.com>
Reviewed-by: Nicolas Schier <nicolas.schier@linux.dev>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
scripts/kconfig/lxdialog/inputbox.c

index 3c6e24b20f5be618164a1c7025fc2ed6bed8a4a5..5e4a131724f2880cfb053149b94609512598063a 100644 (file)
@@ -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';
+       }
 
 do_resize:
        if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGHT_MIN))