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

index d98c868c148b6cff5f05f555a20547c76ca19f91..b2e7310ca0b8e05d9835c4898f9670993d5ebed3 100644 (file)
@@ -109,7 +109,8 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 pid, u32 seq, u32 type,
        nfmsg->version = NFNETLINK_V0;
        nfmsg->res_id = 0;
 
-       NLA_PUT_STRING(skb, NFACCT_NAME, acct->name);
+       if (nla_put_string(skb, NFACCT_NAME, acct->name))
+               goto nla_put_failure;
 
        if (type == NFNL_MSG_ACCT_GET_CTRZERO) {
                pkts = atomic64_xchg(&acct->pkts, 0);
@@ -118,9 +119,10 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 pid, u32 seq, u32 type,
                pkts = atomic64_read(&acct->pkts);
                bytes = atomic64_read(&acct->bytes);
        }
-       NLA_PUT_BE64(skb, NFACCT_PKTS, cpu_to_be64(pkts));
-       NLA_PUT_BE64(skb, NFACCT_BYTES, cpu_to_be64(bytes));
-       NLA_PUT_BE32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt)));
+       if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) ||
+           nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) ||
+           nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt))))
+               goto nla_put_failure;
 
        nlmsg_end(skb, nlh);
        return skb->len;