Skip to content

Commit 1918f98

Browse files
suchit07-gitmasahir0y
authored andcommitted
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 <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent eb549e1 commit 1918f98

File tree

1 file changed

+1
-2
lines changed
  • scripts/kconfig/lxdialog

1 file changed

+1
-2
lines changed

scripts/kconfig/lxdialog/util.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
345345
int prompt_len, room, wlen;
346346
char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
347347

348-
strcpy(tempstr, prompt);
349-
348+
snprintf(tempstr, sizeof(tempstr), "%s", prompt);
350349
prompt_len = strlen(tempstr);
351350

352351
if (prompt_len <= width - x * 2) { /* If prompt is short */

0 commit comments

Comments
 (0)