On 8/10/25 7:22 AM, Thorsten Blum wrote:
Use 'min(len, x)' as the index instead of just 'len' to NUL-terminate the copied 'line' string at the correct position.
Add a newline after the local variable declarations to silence a checkpatch warning.
Cc: stable@vger.kernel.org Fixes: 692d97c380c6 ("kconfig: new configuration interface (nconfig)") Signed-off-by: Thorsten Blum thorsten.blum@linux.dev
LGTM. Thanks.
Reviewed-by: Randy Dunlap rdunlap@infradead.org
scripts/kconfig/nconf.gui.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 7206437e784a..ec021ebd2c52 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -175,8 +175,9 @@ void fill_window(WINDOW *win, const char *text) for (i = 0; i < total_lines; i++) { char tmp[x+10]; const char *line = get_line(text, i);
int len = get_line_length(line);
strncpy(tmp, line, min(len, x));
int len = min(get_line_length(line), x);
tmp[len] = '\0'; mvwprintw(win, i, 0, "%s", tmp); }strncpy(tmp, line, len);