]> granicus.if.org Git - ipset/commitdiff
Resolve the STREQ macro to make the code more readable, and use nla_strlcpy where...
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 10 Dec 2014 06:27:35 +0000 (07:27 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 10 Dec 2014 06:27:35 +0000 (07:27 +0100)
kernel/net/netfilter/ipset/ip_set_hash_netiface.c

index d7bdb06ecca08cf0e3fdca2a41f0ad173e5ee0cb..8a182adac1ca827b5beefcf23e3ab8e874c26c6b 100644 (file)
@@ -41,8 +41,7 @@ MODULE_ALIAS("ip_set_hash:net,iface");
 #define IP_SET_HASH_WITH_MULTI
 #define IP_SET_HASH_WITH_NET0
 
-#define STREQ(a, b)    (strcmp(a, b) == 0)
-#define IFNAMCPY(a, b) strncpy(a, b, IFNAMSIZ)
+#define IFNAMCPY(a, b) strlcpy(a, b, IFNAMSIZ)
 
 /* IPv4 variant */
 
@@ -75,7 +74,7 @@ hash_netiface4_data_equal(const struct hash_netiface4_elem *ip1,
               ip1->cidr == ip2->cidr &&
               (++*multi) &&
               ip1->physdev == ip2->physdev &&
-              STREQ(ip1->iface, ip2->iface);
+              strcmp(ip1->iface, ip2->iface) == 0;
 }
 
 static inline int
@@ -214,7 +213,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
                if (e.cidr > HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
-       IFNAMCPY(e.iface, nla_data(tb[IPSET_ATTR_IFACE]));
+       nla_strlcpy(e.iface, tb[IPSET_ATTR_IFACE], IFNAMSIZ);
 
        if (tb[IPSET_ATTR_CADT_FLAGS]) {
                u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
@@ -288,7 +287,7 @@ hash_netiface6_data_equal(const struct hash_netiface6_elem *ip1,
               ip1->cidr == ip2->cidr &&
               (++*multi) &&
               ip1->physdev == ip2->physdev &&
-              STREQ(ip1->iface, ip2->iface);
+              strcmp(ip1->iface, ip2->iface) == 0;
 }
 
 static inline int
@@ -430,7 +429,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_INVALID_CIDR;
        ip6_netmask(&e.ip, e.cidr);
 
-       IFNAMCPY(e.iface, nla_data(tb[IPSET_ATTR_IFACE]));
+       nla_strlcpy(e.iface, tb[IPSET_ATTR_IFACE], IFNAMSIZ);
 
        if (tb[IPSET_ATTR_CADT_FLAGS]) {
                u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);