diff options
author | David S. Miller <davem@davemloft.net> | 2012-04-01 20:40:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-02 04:33:43 -0400 |
commit | d317e4f68f5445e536dbd45381e7c900a33413db (patch) | |
tree | 7212db7295276d22e98d175e6699672f866b9b3d /net | |
parent | f3756b79e8f76cb92830383c215deba146fe0a26 (diff) |
netfilter: ipv4: Stop using NLA_PUT*().
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 5 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 12 |
2 files changed, 9 insertions, 8 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index de9da21113a1..5c45e30cf788 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
@@ -303,8 +303,9 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len) | |||
303 | static int ipv4_tuple_to_nlattr(struct sk_buff *skb, | 303 | static int ipv4_tuple_to_nlattr(struct sk_buff *skb, |
304 | const struct nf_conntrack_tuple *tuple) | 304 | const struct nf_conntrack_tuple *tuple) |
305 | { | 305 | { |
306 | NLA_PUT_BE32(skb, CTA_IP_V4_SRC, tuple->src.u3.ip); | 306 | if (nla_put_be32(skb, CTA_IP_V4_SRC, tuple->src.u3.ip) || |
307 | NLA_PUT_BE32(skb, CTA_IP_V4_DST, tuple->dst.u3.ip); | 307 | nla_put_be32(skb, CTA_IP_V4_DST, tuple->dst.u3.ip)) |
308 | goto nla_put_failure; | ||
308 | return 0; | 309 | return 0; |
309 | 310 | ||
310 | nla_put_failure: | 311 | nla_put_failure: |
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index 7cbe9cb261c2..0847e373d33c 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
@@ -228,10 +228,10 @@ icmp_error(struct net *net, struct nf_conn *tmpl, | |||
228 | static int icmp_tuple_to_nlattr(struct sk_buff *skb, | 228 | static int icmp_tuple_to_nlattr(struct sk_buff *skb, |
229 | const struct nf_conntrack_tuple *t) | 229 | const struct nf_conntrack_tuple *t) |
230 | { | 230 | { |
231 | NLA_PUT_BE16(skb, CTA_PROTO_ICMP_ID, t->src.u.icmp.id); | 231 | if (nla_put_be16(skb, CTA_PROTO_ICMP_ID, t->src.u.icmp.id) || |
232 | NLA_PUT_U8(skb, CTA_PROTO_ICMP_TYPE, t->dst.u.icmp.type); | 232 | nla_put_u8(skb, CTA_PROTO_ICMP_TYPE, t->dst.u.icmp.type) || |
233 | NLA_PUT_U8(skb, CTA_PROTO_ICMP_CODE, t->dst.u.icmp.code); | 233 | nla_put_u8(skb, CTA_PROTO_ICMP_CODE, t->dst.u.icmp.code)) |
234 | 234 | goto nla_put_failure; | |
235 | return 0; | 235 | return 0; |
236 | 236 | ||
237 | nla_put_failure: | 237 | nla_put_failure: |
@@ -293,8 +293,8 @@ icmp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) | |||
293 | { | 293 | { |
294 | const unsigned int *timeout = data; | 294 | const unsigned int *timeout = data; |
295 | 295 | ||
296 | NLA_PUT_BE32(skb, CTA_TIMEOUT_ICMP_TIMEOUT, htonl(*timeout / HZ)); | 296 | if (nla_put_be32(skb, CTA_TIMEOUT_ICMP_TIMEOUT, htonl(*timeout / HZ))) |
297 | 297 | goto nla_put_failure; | |
298 | return 0; | 298 | return 0; |
299 | 299 | ||
300 | nla_put_failure: | 300 | nla_put_failure: |