]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: xtables: Use strscpy() instead of strscpy_pad()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 18 Mar 2025 18:55:19 +0000 (19:55 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 23 Mar 2025 09:53:47 +0000 (10:53 +0100)
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

index 5d1fb7018dbac3451efffd0a15e5294860517f08..600060ca940af518fc77be1c828a98848905fafc 100644 (file)
@@ -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; \