public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: Replace strncpy() with strscpy()
@ 2025-03-17  7:22 feng.wei8
  2025-03-17  8:50 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: feng.wei8 @ 2025-03-17  7:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: masahiroy, linux-kbuild

From: FengWei <feng.wei8@zte.com.cn>

supplemented:
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..e547ce003f00 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -970,8 +970,7 @@ static int conf_touch_deps(void)
 	if (depfile_prefix_len + 1 > sizeof(depfile_path))
 		return -1;

-	strncpy(depfile_path, name, depfile_prefix_len);
-	depfile_path[depfile_prefix_len] = 0;
+	strscpy(depfile_path, name, depfile_prefix_len);

 	conf_read_simple(name, S_DEF_AUTO);

-- 
2.25.1

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

* Re: [PATCH] kconfig: Replace strncpy() with strscpy()
  2025-03-17  7:22 [PATCH] kconfig: Replace strncpy() with strscpy() feng.wei8
@ 2025-03-17  8:50 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2025-03-17  8:50 UTC (permalink / raw)
  To: feng.wei8, linux-kernel; +Cc: masahiroy, linux-kbuild

On 17. 03. 25, 8:22, feng.wei8@zte.com.cn wrote:
> From: FengWei <feng.wei8@zte.com.cn>
> 
> supplemented:
> 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..e547ce003f00 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -970,8 +970,7 @@ static int conf_touch_deps(void)
>   	if (depfile_prefix_len + 1 > sizeof(depfile_path))
>   		return -1;
> 
> -	strncpy(depfile_path, name, depfile_prefix_len);
> -	depfile_path[depfile_prefix_len] = 0;
> +	strscpy(depfile_path, name, depfile_prefix_len);

Are you aware this is userspace?

So: do you even compile-test all this?

-- 
js
suse labs


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

end of thread, other threads:[~2025-03-17  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  7:22 [PATCH] kconfig: Replace strncpy() with strscpy() feng.wei8
2025-03-17  8:50 ` Jiri Slaby

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