[PATCH] kconfig: Replace deprecated strncpy() with strscpy()

feng.wei8@zte.com.cn posted 1 patch 9 months ago
scripts/kconfig/confdata.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] kconfig: Replace deprecated strncpy() with strscpy()
Posted by feng.wei8@zte.com.cn 9 months ago
From: FengWei <feng.wei8@zte.com.cn>

strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.

Signed-off-by: FengWei <feng.wei8@zte.com.cn>
---
 scripts/kconfig/confdata.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ac95661a1c9d..712ed0602292 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -99,8 +99,7 @@ static int make_parent_dir(const char *path)
 	char tmp[PATH_MAX + 1];
 	char *p;

-	strncpy(tmp, path, sizeof(tmp));
-	tmp[sizeof(tmp) - 1] = 0;
+	strscpy(tmp, path, sizeof(tmp));

 	/* Remove the base name. Just return if nothing is left */
 	p = strrchr(tmp, '/');
-- 
2.25.1