diff options
| author | Suchit Karunakaran <suchitkarunakaran@gmail.com> | 2025-07-27 22:14:33 +0530 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-28 16:28:29 +0200 |
| commit | 98b7b47cebe30086860f769794f8643ea0d89a16 (patch) | |
| tree | e4f0a6c1bc694ca468cfaa819228bb02e054145f /scripts | |
| parent | b45134f726426d339bb3f7fdd19eed70c342863c (diff) | |
| download | linux-98b7b47cebe30086860f769794f8643ea0d89a16.tar.gz linux-98b7b47cebe30086860f769794f8643ea0d89a16.tar.bz2 linux-98b7b47cebe30086860f769794f8643ea0d89a16.zip | |
kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c
[ 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>
Diffstat (limited to 'scripts')
| -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 1dcfb288ee63..327b60cdb8da 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_HEIGTH_MIN)) |
