X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=net%2Fipv4%2Fnetfilter%2Fnf_nat_proto_common.c;h=ccb69ce159894674202170be0340ca87f6ca3ce7;hp=f52d41ea06901253e1eae173201c8d3e613ea0c8;hb=6eab16489865086d2891939ea069d0983b9c44dd;hpb=dc47d3810cdcb4f32bfa31d50f26af97aced0638 diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index f52d41ea0690..ccb69ce15989 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,7 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, const struct nf_conn *ct, u_int16_t *rover) { - unsigned int range_size, min, i; + unsigned int range_size, min, max, i; __be16 *portptr; u_int16_t off; @@ -71,7 +72,10 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, } } else { min = ntohs(range->min.all); - range_size = ntohs(range->max.all) - min + 1; + max = ntohs(range->max.all); + if (unlikely(max < min)) + swap(max, min); + range_size = max - min + 1; } if (range->flags & IP_NAT_RANGE_PROTO_RANDOM)