X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fipv4%2Fnetfilter%2Fnf_nat_proto_common.c;h=ccb69ce159894674202170be0340ca87f6ca3ce7;hb=6eab16489865086d2891939ea069d0983b9c44dd;hp=a3d997618602496867a7456b8205c80585d2ec75;hpb=09521577ca7718b6c83f095ca4f0d474b01a8378;p=pandora-kernel.git diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index a3d997618602..ccb69ce15989 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c @@ -42,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; @@ -72,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)