kconfig/nconf: Replace deprecated strncpy() with strscpy()
PATCH 1/1 kconfig/nconf: Replace deprecated strncpy() with strscpy()
The use of strncpy() does not guarantee null-termination and is deprecated in the kernel. This change replaces it with strscpy(), which ensures null-termination and returns a value indicating truncation.
In this case, padding the destination buffer is not necessary since the string is used in a UI context as a null-terminated string. Therefore, strscpy() is a safer and more efficient replacement. See: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by Shankari Anand <[email protected]>
--- scripts/kconfig/nconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/nconf.c +1 -1
@@ -589,7 +589,7 @@ static void item_add_str(const char *fmt, ...)va_end (ap);snprintf (tmp_str,sizeof (tmp_str),"%s%s" , k_menu_items[index].str, new_str); -strncpy (k_menu_items[index].str, +strscpy (k_menu_items[index].str, tmp_str,sizeof (k_menu_items[index].str));
Signature · 1 line
2.34.1