diff options
| author | Suchit Karunakaran <suchitkarunakaran@gmail.com> | 2025-07-27 22:14:33 +0530 |
|---|---|---|
| committer | Masahiro Yamada <masahiroy@kernel.org> | 2025-08-06 10:23:36 +0900 |
| commit | 5ac726653a1029a2eccba93bbe59e01fc9725828 (patch) | |
| tree | 71ab56febe0d834080f91f12a884789dff57335d | |
| parent | 1918f983687aa73bf0e5bc73431898994fce35a8 (diff) | |
| download | linux-5ac726653a1029a2eccba93bbe59e01fc9725828.tar.gz | |
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>
| -rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 3c6e24b20f5be6..5e4a131724f288 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'; + } do_resize: if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGHT_MIN)) |
