]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
netfilter: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 7 Nov 2022 21:09:04 +0000 (22:09 +0100)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 7 Nov 2022 21:09:04 +0000 (22:09 +0100)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Florian Westphal <fw@strlen.de>
kernel/net/netfilter/ipset/ip_set_core.c

index 037b2ce91b3f3be3a8340e252a75fcd0bac8d852..77fb55cd4bace77ad74d51349f20d8627dddbae5 100644 (file)
@@ -354,7 +354,7 @@ ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment,
        c = kmalloc(sizeof(*c) + len + 1, GFP_ATOMIC);
        if (unlikely(!c))
                return;
-       strlcpy(c->str, ext->comment, len + 1);
+       strscpy(c->str, ext->comment, len + 1);
        set->ext_size += sizeof(*c) + strlen(c->str) + 1;
        rcu_assign_pointer(comment->c, c);
 }
@@ -1082,7 +1082,7 @@ IPSET_CBFN(ip_set_create, struct net *n, struct sock *ctnl,
        if (!set)
                return -ENOMEM;
        spin_lock_init(&set->lock);
-       strlcpy(set->name, name, IPSET_MAXNAMELEN);
+       strscpy(set->name, name, IPSET_MAXNAMELEN);
        set->family = family;
        set->revision = revision;