Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: xtables: Use strscpy() instead of strscpy_pad()

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>

authored by

Thorsten Blum and committed by
Pablo Neira Ayuso
3b4aff61 778b09d9

+1 -1
+1 -1
net/netfilter/xt_repldata.h
··· 29 29 if (tbl == NULL) \ 30 30 return NULL; \ 31 31 term = (struct type##_error *)&(((char *)tbl)[term_offset]); \ 32 - strscpy_pad(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \ 32 + strscpy(tbl->repl.name, info->name); \ 33 33 *term = (struct type##_error)typ2##_ERROR_INIT; \ 34 34 tbl->repl.valid_hooks = hook_mask; \ 35 35 tbl->repl.num_entries = nhooks + 1; \