]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
kconfig: lxdialog: replace strcpy with snprintf in print_autowrap
authorSuchit Karunakaran <suchitkarunakaran@gmail.com>
Sat, 26 Jul 2025 19:43:07 +0000 (01:13 +0530)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 6 Aug 2025 01:23:36 +0000 (10:23 +0900)
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>
scripts/kconfig/lxdialog/util.c

index 964139c87fcb3acfb957718f5a519302c969965c..b34000beb294879585dcdef63a5621c3fb583442 100644 (file)
@@ -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 */