nf_conntrack_proto_udp{,lite}: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:48:06 +0000 (18:48 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:48:06 +0000 (18:48 -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/netfilter/nf_conntrack_proto_udp.c
net/netfilter/nf_conntrack_proto_udplite.c

index a9073dc1548d087fbe694f898ff30072792bc2e6..7259a6bdeb491f4057d5527d1f68ff63a097311b 100644 (file)
@@ -181,10 +181,11 @@ udp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
 {
        const unsigned int *timeouts = data;
 
-       NLA_PUT_BE32(skb, CTA_TIMEOUT_UDP_UNREPLIED,
-                       htonl(timeouts[UDP_CT_UNREPLIED] / HZ));
-       NLA_PUT_BE32(skb, CTA_TIMEOUT_UDP_REPLIED,
-                       htonl(timeouts[UDP_CT_REPLIED] / HZ));
+       if (nla_put_be32(skb, CTA_TIMEOUT_UDP_UNREPLIED,
+                        htonl(timeouts[UDP_CT_UNREPLIED] / HZ)) ||
+           nla_put_be32(skb, CTA_TIMEOUT_UDP_REPLIED,
+                        htonl(timeouts[UDP_CT_REPLIED] / HZ)))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
index e0606392cda053a9d1345d465d503e5e6ab20d42..4d60a5376aa6d418d6cf10f889e6a12f348dd9d2 100644 (file)
@@ -185,10 +185,11 @@ udplite_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
 {
        const unsigned int *timeouts = data;
 
-       NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_UNREPLIED,
-                       htonl(timeouts[UDPLITE_CT_UNREPLIED] / HZ));
-       NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_REPLIED,
-                       htonl(timeouts[UDPLITE_CT_REPLIED] / HZ));
+       if (nla_put_be32(skb, CTA_TIMEOUT_UDPLITE_UNREPLIED,
+                        htonl(timeouts[UDPLITE_CT_UNREPLIED] / HZ)) ||
+           nla_put_be32(skb, CTA_TIMEOUT_UDPLITE_REPLIED,
+                        htonl(timeouts[UDPLITE_CT_REPLIED] / HZ)))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure: