lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250415163536.GA395307@horms.kernel.org>
Date: Tue, 15 Apr 2025 17:35:36 +0100
From: Simon Horman <horms@...nel.org>
To: Pranav Tyagi <pranav.tyagi03@...il.com>
Cc: davem@...emloft.net, dsahern@...nel.org, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, skhan@...uxfoundation.org,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH net-next] net: ipconfig: replace strncpy with strscpy

On Sat, Apr 12, 2025 at 09:36:23PM +0530, Pranav Tyagi wrote:
> Replace the deprecated strncpy() with strscpy() as the destination
> buffer is NUL-terminated and does not require any
> trailing NUL-padding.
> 
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>

Thanks,

I agree that strscpy() is the correct choice here for
the reasons you give above.

Reviewed-by: Simon Horman <horms@...nel.org>

> ---
>  net/ipv4/ipconfig.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
> index c56b6fe6f0d7..eb9b32214e60 100644
> --- a/net/ipv4/ipconfig.c
> +++ b/net/ipv4/ipconfig.c
> @@ -1690,7 +1690,7 @@ static int __init ic_proto_name(char *name)
>  			*v = 0;
>  			if (kstrtou8(client_id, 0, dhcp_client_identifier))
>  				pr_debug("DHCP: Invalid client identifier type\n");
> -			strncpy(dhcp_client_identifier + 1, v + 1, 251);
> +			strscpy(dhcp_client_identifier + 1, v + 1, 251);

As an aside, I'm curious to know why the length is 251
rather than 252 (sizeof(dhcp_client_identifier) -1).
But that isn't strictly related to this patch.

>  			*v = ',';
>  		}
>  		return 1;
> -- 
> 2.49.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ