Skip to contentSkip to conversation

net: ipconfig: replace strncpy with strscpy

PATCH In review Pranav Tyagi 3 participants 4 messages Jun 12, 2025 – Jul 5, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: ipconfig: replace strncpy with strscpy

Replace the deprecated strncpy() with strscpy() as the destination buffer is NUL-terminated and does not require any trailing NUL-padding. Also increase the length to 252 as NUL-termination is guaranteed.

---
 net/ipv4/ipconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ipconfig.c +1 -1
index c56b6fe6f0d7..eb9b32214e60 100644
@@ -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, 252);
 			*v = ',';
 		}
 		return 1;
Signature · 1 line
2.49.0
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Pranav Tyagi

Replace the deprecated strncpy() with strscpy() as the destination buffer is NUL-terminated and does not require any trailing NUL-padding. Also increase the length to 252 as NUL-termination is guaranteed.

Hi Pranav,

Thanks for the updated patch.

I agree with your analysis above and that this patch is correct.

maintainer
#2 lore raw
In reply to Pranav Tyagi
Quoted 4 lines · On Thu, 12 Jun 2025 17:18:59 +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. Also increase the length to 252 as NUL-termination is guaranteed.

Petr is making functional changes to this code:
https://lore.kernel.org/all/[email protected]/
Please repost once his work is merged to avoid unnecessary conflicts

Signature · 1 line
pw-bot: defer
#3 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 12 Jun 2025 17:18:59 +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. Also increase the length to 252 as NUL-termination is guaranteed.

Quoted 5 lines

Petr is making functional changes to this code:
https://lore.kernel.org/all/[email protected]/
Please repost once his work is merged to avoid unnecessary conflicts --
pw-bot: defer

Hi,

I hope you're doing well.

I noticed that Petr’s patch has not seen any updates for some time now. I wanted to kindly ask if it would be appropriate to repost my patch at this point
or if I should continue to wait until his changes are merged.

Thank you for your time and guidance.

Regards
Pranav Tyagi