Skip to content

Commit 5ac7266

Browse files
suchit07-gitmasahir0y
authored andcommitted
kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c
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>
1 parent 1918f98 commit 5ac7266

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/kconfig/lxdialog/inputbox.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
3939

4040
if (!init)
4141
instr[0] = '\0';
42-
else
43-
strcpy(instr, init);
42+
else {
43+
strncpy(instr, init, sizeof(dialog_input_result) - 1);
44+
instr[sizeof(dialog_input_result) - 1] = '\0';
45+
}
4446

4547
do_resize:
4648
if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGHT_MIN))

0 commit comments

Comments
 (0)