netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org,
	pabeni@redhat.com, edumazet@google.com, fw@strlen.de,
	horms@kernel.org
Subject: [PATCH net-next 5/7] netfilter: xtables: Use strscpy() instead of strscpy_pad()
Date: Sun, 23 Mar 2025 11:09:20 +0100	[thread overview]
Message-ID: <20250323100922.59983-6-pablo@netfilter.org> (raw)
In-Reply-To: <20250323100922.59983-1-pablo@netfilter.org>

From: Thorsten Blum <thorsten.blum@linux.dev>

kzalloc() already zero-initializes the destination buffer, making
strscpy() sufficient for safely copying the name. The additional NUL-
padding performed by strscpy_pad() is unnecessary.

The size parameter is optional, and strscpy() automatically determines
the size of the destination buffer using sizeof() if the argument is
omitted. This makes the explicit sizeof() call unnecessary; remove it.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/xt_repldata.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h
index 5d1fb7018dba..600060ca940a 100644
--- a/net/netfilter/xt_repldata.h
+++ b/net/netfilter/xt_repldata.h
@@ -29,7 +29,7 @@
 	if (tbl == NULL) \
 		return NULL; \
 	term = (struct type##_error *)&(((char *)tbl)[term_offset]); \
-	strscpy_pad(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
+	strscpy(tbl->repl.name, info->name); \
 	*term = (struct type##_error)typ2##_ERROR_INIT;  \
 	tbl->repl.valid_hooks = hook_mask; \
 	tbl->repl.num_entries = nhooks + 1; \
-- 
2.30.2


  parent reply	other threads:[~2025-03-23 10:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-23 10:09 [PATCH net-next 0/7] Netfilter updates for net-next Pablo Neira Ayuso
2025-03-23 10:09 ` [PATCH net-next 1/7] netfilter: xt_hashlimit: replace vmalloc calls with kvmalloc Pablo Neira Ayuso
2025-03-25 15:40   ` patchwork-bot+netdevbpf
2025-03-23 10:09 ` [PATCH net-next 2/7] netfilter: conntrack: Bound nf_conntrack sysctl writes Pablo Neira Ayuso
2025-03-23 10:09 ` [PATCH net-next 3/7] netfilter: fib: avoid lookup if socket is available Pablo Neira Ayuso
2025-03-23 10:09 ` [PATCH net-next 4/7] netfilter: nfnetlink_queue: Initialize ctx to avoid memory allocation error Pablo Neira Ayuso
2025-03-23 10:09 ` Pablo Neira Ayuso [this message]
2025-03-23 10:09 ` [PATCH net-next 6/7] netfilter: socket: Lookup orig tuple for IPv6 SNAT Pablo Neira Ayuso
2025-03-23 10:09 ` [PATCH net-next 7/7] netfilter: nf_tables: Only use nf_skip_indirect_calls() when MITIGATION_RETPOLINE Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250323100922.59983-6-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).