diff options
author | Suchit Karunakaran <suchitkarunakaran@gmail.com> | 2025-07-27 01:13:07 +0530 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2025-08-06 10:23:36 +0900 |
commit | 1918f983687aa73bf0e5bc73431898994fce35a8 (patch) | |
tree | c290d1415f777392f71c23d4fbcfae032956fc9c | |
parent | eb549e194bf2d5c86b1b7a71fad54d610dd6c892 (diff) |
kconfig: lxdialog: replace strcpy with snprintf in print_autowrap
strcpy() does not perform bounds checking and can lead to buffer overflows
if the source string exceeds the destination buffer size. In
print_autowrap(), replace strcpy() with snprintf() to safely copy the
prompt string into the fixed-size tempstr buffer.
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index 964139c87fcb..b34000beb294 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -345,8 +345,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) int prompt_len, room, wlen; char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; - strcpy(tempstr, prompt); - + snprintf(tempstr, sizeof(tempstr), "%s", prompt); prompt_len = strlen(tempstr); if (prompt_len <= width - x * 2) { /* If prompt is short */ |