nf_conntrack_core: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:58:28 +0000 (18:58 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:58:28 +0000 (18:58 -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_core.c

index cbdb754dbb10d9a88ab4eef9e1ddf4ff8b3362a6..b0ab8c43abe704c88364478a4c8caa0bd86b5bbb 100644 (file)
@@ -1151,8 +1151,9 @@ static struct nf_ct_ext_type nf_ct_zone_extend __read_mostly = {
 int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
                               const struct nf_conntrack_tuple *tuple)
 {
-       NLA_PUT_BE16(skb, CTA_PROTO_SRC_PORT, tuple->src.u.tcp.port);
-       NLA_PUT_BE16(skb, CTA_PROTO_DST_PORT, tuple->dst.u.tcp.port);
+       if (nla_put_be16(skb, CTA_PROTO_SRC_PORT, tuple->src.u.tcp.port) ||
+           nla_put_be16(skb, CTA_PROTO_DST_PORT, tuple->dst.u.tcp.port))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure: