aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter/xt_repldata.h
diff options
context:
space:
mode:
authorJustin Stitt <justinstitt@google.com>2023-08-09 01:06:10 +0000
committerFlorian Westphal <fw@strlen.de>2023-08-22 15:13:21 +0200
commitaa222dd190d69ca8e0e2b990ec171c67a74d5383 (patch)
treeedf02a205e60f1af1c17f25fb8957ec7cd5ba480 /net/netfilter/xt_repldata.h
parent06f7d3c3f82c3a53de32a2c0c08e96c0d9ef69ec (diff)
downloadlinux-aa222dd190d69ca8e0e2b990ec171c67a74d5383.tar.gz
netfilter: xtables: refactor deprecated strncpy
Prefer `strscpy_pad` as it's a more robust interface whilst maintaing zero-padding behavior. There may have existed a bug here due to both `tbl->repl.name` and `info->name` having a size of 32 as defined below: | #define XT_TABLE_MAXNAMELEN 32 This may lead to buffer overreads in some situations -- `strscpy` solves this by guaranteeing NUL-termination of the dest buffer. Signed-off-by: Justin Stitt <justinstitt@google.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'net/netfilter/xt_repldata.h')
-rw-r--r--net/netfilter/xt_repldata.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h
index 68ccbe50bb1ea..5d1fb7018dbac 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]); \
- strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
+ strscpy_pad(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
*term = (struct type##_error)typ2##_ERROR_INIT; \
tbl->repl.valid_hooks = hook_mask; \
tbl->repl.num_entries = nhooks + 1; \