]> git.karo-electronics.de Git - linux-beck.git/commitdiff
nf_conntrack_proto_sctp: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:51:07 +0000 (18:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:51:39 +0000 (18:51 -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_sctp.c

index 72b5088592dc8557b264c4b0f7de4e72fa3e3b76..996db2fa21f7621cacf70fea4b371fafb8c1bae6 100644 (file)
@@ -482,15 +482,12 @@ static int sctp_to_nlattr(struct sk_buff *skb, struct nlattr *nla,
        if (!nest_parms)
                goto nla_put_failure;
 
-       NLA_PUT_U8(skb, CTA_PROTOINFO_SCTP_STATE, ct->proto.sctp.state);
-
-       NLA_PUT_BE32(skb,
-                    CTA_PROTOINFO_SCTP_VTAG_ORIGINAL,
-                    ct->proto.sctp.vtag[IP_CT_DIR_ORIGINAL]);
-
-       NLA_PUT_BE32(skb,
-                    CTA_PROTOINFO_SCTP_VTAG_REPLY,
-                    ct->proto.sctp.vtag[IP_CT_DIR_REPLY]);
+       if (nla_put_u8(skb, CTA_PROTOINFO_SCTP_STATE, ct->proto.sctp.state) ||
+           nla_put_be32(skb, CTA_PROTOINFO_SCTP_VTAG_ORIGINAL,
+                        ct->proto.sctp.vtag[IP_CT_DIR_ORIGINAL]) ||
+           nla_put_be32(skb, CTA_PROTOINFO_SCTP_VTAG_REPLY,
+                        ct->proto.sctp.vtag[IP_CT_DIR_REPLY]))
+               goto nla_put_failure;
 
        spin_unlock_bh(&ct->lock);
 
@@ -578,9 +575,10 @@ sctp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
         const unsigned int *timeouts = data;
        int i;
 
-       for (i=CTA_TIMEOUT_SCTP_UNSPEC+1; i<CTA_TIMEOUT_SCTP_MAX+1; i++)
-               NLA_PUT_BE32(skb, i, htonl(timeouts[i] / HZ));
-
+       for (i=CTA_TIMEOUT_SCTP_UNSPEC+1; i<CTA_TIMEOUT_SCTP_MAX+1; i++) {
+               if (nla_put_be32(skb, i, htonl(timeouts[i] / HZ)))
+                       goto nla_put_failure;
+       }
         return 0;
 
 nla_put_failure: