public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH v3] kconfig/lxdialog: replace strcpy() with strncpy() in inputbox.c
@ 2025-07-27 16:44 Suchit Karunakaran
  2025-07-27 19:19 ` Nicolas Schier
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Suchit Karunakaran @ 2025-07-27 16:44 UTC (permalink / raw)
  To: masahiroy, nicolas.schier, linux-kbuild
  Cc: skhan, linux-kernel-mentees, linux-kernel, Suchit Karunakaran

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>
---
 scripts/kconfig/lxdialog/inputbox.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 3c6e24b20f5b..5e4a131724f2 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))
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-29 13:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-27 16:44 [PATCH v3] kconfig/lxdialog: replace strcpy() with strncpy() in inputbox.c Suchit Karunakaran
2025-07-27 19:19 ` Nicolas Schier
2025-07-28  3:59   ` Suchit K
2025-07-28  4:29 ` Greg KH
2025-07-28  4:48   ` Suchit K
2025-07-28  5:20     ` Greg KH
     [not found]       ` <CAO9wTFi+atf1vwMrDJBa-X4W5UcQ8K80spgiGhMyhZj4aRJ3Zw@mail.gmail.com>
2025-07-28  5:39         ` Suchit K
2025-07-29 13:40   ` Masahiro Yamada
2025-07-29 13:41 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox