* [PATCH] Removing deprecated strncpy()
@ 2025-04-10 11:32 Kevin Paul Reddy Janagari
2025-04-10 11:54 ` Heiko Carstens
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Paul Reddy Janagari @ 2025-04-10 11:32 UTC (permalink / raw)
To: hca, gor, agordeev, borntraeger, svens, linux-s390, linux-kernel,
kevinpaul468
Cc: skhan
This patch suggests the replacement of strncpy with strscpy
as per the Documentation/process/deprecated
the strncpy() fails to guarntee NULL termination
since the function adds zero pads, this isn't really convenient
for short strings as it may cause performce issues
strscpy() is a preffered replacement because
it overcomes the limitations of strncpy as mentioned above
Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
---
arch/s390/boot/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/boot/printk.c b/arch/s390/boot/printk.c
index 8cf6331bc060..8f3b2244ef1b 100644
--- a/arch/s390/boot/printk.c
+++ b/arch/s390/boot/printk.c
@@ -158,7 +158,7 @@ static noinline char *strsym(char *buf, void *ip)
p = findsym((unsigned long)ip, &off, &len);
if (p) {
- strncpy(buf, p, MAX_SYMLEN);
+ strscpy(buf, p, MAX_SYMLEN);
/* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */
p = buf + strnlen(buf, MAX_SYMLEN - 15);
strcpy(p, "+0x");
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] Removing deprecated strncpy()
2025-04-10 11:32 [PATCH] Removing deprecated strncpy() Kevin Paul Reddy Janagari
@ 2025-04-10 11:54 ` Heiko Carstens
0 siblings, 0 replies; 6+ messages in thread
From: Heiko Carstens @ 2025-04-10 11:54 UTC (permalink / raw)
To: Kevin Paul Reddy Janagari
Cc: gor, agordeev, borntraeger, svens, linux-s390, linux-kernel,
skhan
On Thu, Apr 10, 2025 at 05:02:30PM +0530, Kevin Paul Reddy Janagari wrote:
> This patch suggests the replacement of strncpy with strscpy
> as per the Documentation/process/deprecated
> the strncpy() fails to guarntee NULL termination
> since the function adds zero pads, this isn't really convenient
> for short strings as it may cause performce issues
>
> strscpy() is a preffered replacement because
> it overcomes the limitations of strncpy as mentioned above
>
> Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
> ---
> arch/s390/boot/printk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/boot/printk.c b/arch/s390/boot/printk.c
> index 8cf6331bc060..8f3b2244ef1b 100644
> --- a/arch/s390/boot/printk.c
> +++ b/arch/s390/boot/printk.c
> @@ -158,7 +158,7 @@ static noinline char *strsym(char *buf, void *ip)
>
> p = findsym((unsigned long)ip, &off, &len);
> if (p) {
> - strncpy(buf, p, MAX_SYMLEN);
> + strscpy(buf, p, MAX_SYMLEN);
This won't even compile. Please compile test before sending any patches.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Removing deprecated strncpy()
@ 2025-04-10 12:32 Kevin Paul Reddy Janagari
2025-04-11 1:10 ` Tung Quang Nguyen
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Paul Reddy Janagari @ 2025-04-10 12:32 UTC (permalink / raw)
To: jmaloy, davem, edumazet, kuba, pabeni, horms
Cc: netdev, tipc-discussion, linux-kernel, Kevin Paul Reddy Janagari
This patch suggests the replacement of strncpy with strscpy
as per Documentation/process/deprecated.
The strncpy() fails to guarntee NULL termination,
The function adds zero pads which isn't really convenient for short strings
as it may cause performce issues
strscpy() is a preffered replacement because
it overcomes the limitations of strncpy mentioned above
Compile Tested
Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
---
net/tipc/link.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 50c2e0846ea4..4859b3ccc094 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2227,7 +2227,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
break;
if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME)
break;
- strncpy(if_name, data, TIPC_MAX_IF_NAME);
+ strscpy(if_name, data, TIPC_MAX_IF_NAME);
/* Update own tolerance if peer indicates a non-zero value */
if (tipc_in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) {
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: [PATCH] Removing deprecated strncpy()
2025-04-10 12:32 Kevin Paul Reddy Janagari
@ 2025-04-11 1:10 ` Tung Quang Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Tung Quang Nguyen @ 2025-04-11 1:10 UTC (permalink / raw)
To: Kevin Paul Reddy Janagari, jmaloy@redhat.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org
Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
>which isn't really convenient for short strings as it may cause performce issues
Typo: /performce/performance
Also please append net-next to [PATCH] in your email subject.
>
>strscpy() is a preffered replacement because it overcomes the limitations of
>strncpy mentioned above
>
>Compile Tested
>Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
>---
> net/tipc/link.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/tipc/link.c b/net/tipc/link.c index 50c2e0846ea4..4859b3ccc094
>100644
>--- a/net/tipc/link.c
>+++ b/net/tipc/link.c
>@@ -2227,7 +2227,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct
>sk_buff *skb,
> break;
> if (msg_data_sz(hdr) < TIPC_MAX_IF_NAME)
> break;
>- strncpy(if_name, data, TIPC_MAX_IF_NAME);
>+ strscpy(if_name, data, TIPC_MAX_IF_NAME);
Could you please do the same replacement in function tipc_node_get_linkname() (node.c) ?
>
> /* Update own tolerance if peer indicates a non-zero value */
> if (tipc_in_range(peers_tol, TIPC_MIN_LINK_TOL,
>TIPC_MAX_LINK_TOL)) {
>--
>2.39.5
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Removing deprecated strncpy()
@ 2025-04-11 5:06 Kevin Paul Reddy Janagari
2025-04-11 5:22 ` Tung Quang Nguyen
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Paul Reddy Janagari @ 2025-04-11 5:06 UTC (permalink / raw)
To: jmaloy
Cc: davem, edumazet, kuba, pabeni, horms, netdev, tipc-discussion,
linux-kernel, kevinpaul468
This patch suggests the replacement of strncpy with strscpy
as per Documentation/process/deprecated.
The strncpy() fails to guarntee NULL termination,
The function adds zero pads which isn't really convenient for short strings
as it may cause performce issues
strscpy() is a preffered replacement because
it overcomes the limitations of strncpy mentioned above
Compile Tested
Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
---
net/tipc/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index ccf5e427f43e..cb43f2016a70 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1581,7 +1581,7 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,
tipc_node_read_lock(node);
link = node->links[bearer_id].link;
if (link) {
- strncpy(linkname, tipc_link_name(link), len);
+ strscpy(linkname, tipc_link_name(link), len);
err = 0;
}
tipc_node_read_unlock(node);
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: [PATCH] Removing deprecated strncpy()
2025-04-11 5:06 Kevin Paul Reddy Janagari
@ 2025-04-11 5:22 ` Tung Quang Nguyen
0 siblings, 0 replies; 6+ messages in thread
From: Tung Quang Nguyen @ 2025-04-11 5:22 UTC (permalink / raw)
To: Kevin Paul Reddy Janagari, jmaloy@redhat.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
>This patch suggests the replacement of strncpy with strscpy as per
>Documentation/process/deprecated.
>The strncpy() fails to guarntee NULL termination, The function adds zero pads
>which isn't really convenient for short strings as it may cause performce issues
>
>strscpy() is a preffered replacement because it overcomes the limitations of
>strncpy mentioned above
>
Please read my comment for your previous patch:
- Add "net-next" to your email subject like this: [PATCH net-next]
- Fix many typos in your changelog: guarntee -> guarantee, performce --> performance, preffered --> preferred
>Compile Tested
>
>Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
>---
> net/tipc/node.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/tipc/node.c b/net/tipc/node.c index
>ccf5e427f43e..cb43f2016a70 100644
>--- a/net/tipc/node.c
>+++ b/net/tipc/node.c
>@@ -1581,7 +1581,7 @@ int tipc_node_get_linkname(struct net *net, u32
>bearer_id, u32 addr,
> tipc_node_read_lock(node);
> link = node->links[bearer_id].link;
> if (link) {
>- strncpy(linkname, tipc_link_name(link), len);
>+ strscpy(linkname, tipc_link_name(link), len);
please merge this change into your previous patch. We do not need a separate patch for the same purpose.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-11 5:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 11:32 [PATCH] Removing deprecated strncpy() Kevin Paul Reddy Janagari
2025-04-10 11:54 ` Heiko Carstens
-- strict thread matches above, loose matches on Subject: below --
2025-04-10 12:32 Kevin Paul Reddy Janagari
2025-04-11 1:10 ` Tung Quang Nguyen
2025-04-11 5:06 Kevin Paul Reddy Janagari
2025-04-11 5:22 ` Tung Quang Nguyen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.