]> www.infradead.org Git - nvme.git/commitdiff
netfilter: x_tables: refactor deprecated strncpy
authorJustin Stitt <justinstitt@google.com>
Wed, 9 Aug 2023 01:06:09 +0000 (01:06 +0000)
committerFlorian Westphal <fw@strlen.de>
Tue, 22 Aug 2023 13:13:21 +0000 (15:13 +0200)
Prefer `strscpy_pad` to `strncpy`.

Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/x_tables.c

index 470282cf3fae61884894765965105c96537dc3a2..21624d68314f98b58c63ae44a65422e448afc023 100644 (file)
@@ -768,7 +768,7 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
        m->u.user.match_size = msize;
        strscpy(name, match->name, sizeof(name));
        module_put(match->me);
-       strncpy(m->u.user.name, name, sizeof(m->u.user.name));
+       strscpy_pad(m->u.user.name, name, sizeof(m->u.user.name));
 
        *size += off;
        *dstptr += msize;
@@ -1148,7 +1148,7 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
        t->u.user.target_size = tsize;
        strscpy(name, target->name, sizeof(name));
        module_put(target->me);
-       strncpy(t->u.user.name, name, sizeof(t->u.user.name));
+       strscpy_pad(t->u.user.name, name, sizeof(t->u.user.name));
 
        *size += off;
        *dstptr += tsize;
@@ -2014,4 +2014,3 @@ static void __exit xt_fini(void)
 
 module_init(xt_init);
 module_exit(xt_fini);
-