netfilter: ipv6: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 00:28:52 +0000 (20:28 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 08:33:43 +0000 (04:33 -0400)
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c

index 4111050a9fc524e0cd225aa81d5dfa4c4e166d06..fe925e492520c5d0ec8226618bfd84d828ebab08 100644 (file)
@@ -278,10 +278,11 @@ static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = {
 static int ipv6_tuple_to_nlattr(struct sk_buff *skb,
                                const struct nf_conntrack_tuple *tuple)
 {
-       NLA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4,
-               &tuple->src.u3.ip6);
-       NLA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4,
-               &tuple->dst.u3.ip6);
+       if (nla_put(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4,
+                   &tuple->src.u3.ip6) ||
+           nla_put(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4,
+                   &tuple->dst.u3.ip6))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
index 92cc9f2931ae46367a7e5fad02e3f31d7978069c..3e81904fbbcdf09b13c2b830bd40f0b2b7ed313a 100644 (file)
@@ -234,10 +234,10 @@ icmpv6_error(struct net *net, struct nf_conn *tmpl,
 static int icmpv6_tuple_to_nlattr(struct sk_buff *skb,
                                  const struct nf_conntrack_tuple *t)
 {
-       NLA_PUT_BE16(skb, CTA_PROTO_ICMPV6_ID, t->src.u.icmp.id);
-       NLA_PUT_U8(skb, CTA_PROTO_ICMPV6_TYPE, t->dst.u.icmp.type);
-       NLA_PUT_U8(skb, CTA_PROTO_ICMPV6_CODE, t->dst.u.icmp.code);
-
+       if (nla_put_be16(skb, CTA_PROTO_ICMPV6_ID, t->src.u.icmp.id) ||
+           nla_put_u8(skb, CTA_PROTO_ICMPV6_TYPE, t->dst.u.icmp.type) ||
+           nla_put_u8(skb, CTA_PROTO_ICMPV6_CODE, t->dst.u.icmp.code))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
@@ -300,8 +300,8 @@ icmpv6_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
 {
        const unsigned int *timeout = data;
 
-       NLA_PUT_BE32(skb, CTA_TIMEOUT_ICMPV6_TIMEOUT, htonl(*timeout / HZ));
-
+       if (nla_put_be32(skb, CTA_TIMEOUT_ICMPV6_TIMEOUT, htonl(*timeout / HZ)))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
This page took 0.027707 seconds and 5 git commands to generate.