[PATCH v2] kconfig: nconf: Fix uncleared lines on help screens

Shankari Anand posted 1 patch 2 months, 2 weeks ago
scripts/kconfig/nconf.gui.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] kconfig: nconf: Fix uncleared lines on help screens
Posted by Shankari Anand 2 months, 2 weeks ago
Commit 1b92b18ec419 ("kconfig: nconf: Ensure null termination where
strncpy is used") introduced a regression where
help screens (F1, F2, F3) no longer properly clear short lines of text,
resulting in duplicated or trailing content when lines are overwritten.

Revert the null-termination change to match
the actual length of the copied string.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Closes: https://lore.kernel.org/lkml/CAK7LNAT54nvwYmTy20Ep8U2kr4thn68yYWXi9R-d3Yx3iXs=Bg@mail.gmail.com/T/#
Fixes: 1b92b18ec419 ("kconfig: nconf: Ensure null termination where strncpy is used")
Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
---
v1 -> v2: Add closes tag to the report.
Carry-forwarded acked-by and tested-by from previous version
---
 scripts/kconfig/nconf.gui.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 475a403ab8ba..7206437e784a 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -177,7 +177,7 @@ void fill_window(WINDOW *win, const char *text)
 		const char *line = get_line(text, i);
 		int len = get_line_length(line);
 		strncpy(tmp, line, min(len, x));
-		tmp[sizeof(tmp) - 1] = '\0';
+		tmp[len] = '\0';
 		mvwprintw(win, i, 0, "%s", tmp);
 	}
 }

base-commit: 05adbee3ad528100ab0285c15c91100e19e10138
-- 
2.34.1
Re: [PATCH v2] kconfig: nconf: Fix uncleared lines on help screens
Posted by Masahiro Yamada 2 months, 1 week ago
On Wed, Jul 23, 2025 at 2:29 AM Shankari Anand
<shankari.ak0208@gmail.com> wrote:
>
> Commit 1b92b18ec419 ("kconfig: nconf: Ensure null termination where
> strncpy is used") introduced a regression where
> help screens (F1, F2, F3) no longer properly clear short lines of text,
> resulting in duplicated or trailing content when lines are overwritten.
>
> Revert the null-termination change to match
> the actual length of the copied string.
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Closes: https://lore.kernel.org/lkml/CAK7LNAT54nvwYmTy20Ep8U2kr4thn68yYWXi9R-d3Yx3iXs=Bg@mail.gmail.com/T/#
> Fixes: 1b92b18ec419 ("kconfig: nconf: Ensure null termination where strncpy is used")
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>
> Tested-by: Randy Dunlap <rdunlap@infradead.org>

Squashed to 1b92b18.
Thanks.


> ---
> v1 -> v2: Add closes tag to the report.
> Carry-forwarded acked-by and tested-by from previous version
> ---
>  scripts/kconfig/nconf.gui.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
> index 475a403ab8ba..7206437e784a 100644
> --- a/scripts/kconfig/nconf.gui.c
> +++ b/scripts/kconfig/nconf.gui.c
> @@ -177,7 +177,7 @@ void fill_window(WINDOW *win, const char *text)
>                 const char *line = get_line(text, i);
>                 int len = get_line_length(line);
>                 strncpy(tmp, line, min(len, x));
> -               tmp[sizeof(tmp) - 1] = '\0';
> +               tmp[len] = '\0';
>                 mvwprintw(win, i, 0, "%s", tmp);
>         }
>  }
>
> base-commit: 05adbee3ad528100ab0285c15c91100e19e10138
> --
> 2.34.1
>


-- 
Best Regards
Masahiro Yamada
Re: [PATCH v2] kconfig: nconf: Fix uncleared lines on help screens
Posted by Nicolas Schier 2 months, 2 weeks ago
On Tue, Jul 22, 2025 at 10:58:37PM +0530, Shankari Anand wrote:
> Commit 1b92b18ec419 ("kconfig: nconf: Ensure null termination where
> strncpy is used") introduced a regression where
> help screens (F1, F2, F3) no longer properly clear short lines of text,
> resulting in duplicated or trailing content when lines are overwritten.
> 
> Revert the null-termination change to match
> the actual length of the copied string.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Closes: https://lore.kernel.org/lkml/CAK7LNAT54nvwYmTy20Ep8U2kr4thn68yYWXi9R-d3Yx3iXs=Bg@mail.gmail.com/T/#
> Fixes: 1b92b18ec419 ("kconfig: nconf: Ensure null termination where strncpy is used")
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>
> Tested-by: Randy Dunlap <rdunlap@infradead.org>
> ---

Tested-by: Nicolas Schier <n.schier@avm.de>
Acked-by: Nicolas Schier <n.schier@avm.de>