2bc4609feb
From upstream: http://hg.dovecot.org/dovecot-1.0/rev/71c02fdf1b59 via brad@
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
$OpenBSD: patch-src_auth_auth-request_c,v 1.1 2008/05/16 05:45:26 bernd Exp $
|
|
|
|
"allow_nets didn't work correctly with big endian machines."
|
|
|
|
From upstream:
|
|
http://hg.dovecot.org/dovecot-1.0/rev/71c02fdf1b59
|
|
|
|
--- src/auth/auth-request.c.orig Thu May 15 01:43:22 2008
|
|
+++ src/auth/auth-request.c Thu May 15 01:45:49 2008
|
|
@@ -825,7 +825,7 @@ static int is_ip_in_network(const char *network, const
|
|
struct ip_addr src_ip, net_ip;
|
|
const char *p;
|
|
unsigned int max_bits, bits, pos, i;
|
|
- uint32_t mask;
|
|
+ uint32_t mask, i1, i2;
|
|
|
|
if (net_ipv6_mapped_ipv4_convert(ip, &src_ip) == 0)
|
|
ip = &src_ip;
|
|
@@ -860,17 +860,19 @@ static int is_ip_in_network(const char *network, const
|
|
if (ip1[i] != ip2[i])
|
|
return 0;
|
|
}
|
|
+ i1 = htonl(ip1[i]);
|
|
+ i2 = htonl(ip2[i]);
|
|
|
|
/* check the last full bytes */
|
|
- for (mask = 0xff; pos + 8 <= bits; pos += 8, mask <<= 8) {
|
|
- if ((ip1[i] & mask) != (ip2[i] & mask))
|
|
+ for (mask = 0xff000000; pos + 8 <= bits; pos += 8, mask >>= 8) {
|
|
+ if ((i1 & mask) != (i2 & mask))
|
|
return 0;
|
|
}
|
|
|
|
/* check the last bits, they're reversed in bytes */
|
|
bits -= pos;
|
|
- for (mask = 0x80 << (pos % 32); bits > 0; bits--, mask >>= 1) {
|
|
- if ((ip1[i] & mask) != (ip2[i] & mask))
|
|
+ for (mask = 0x80000000 >> (pos % 32); bits > 0; bits--, mask >>= 1) {
|
|
+ if ((i1 & mask) != (i2 & mask))
|
|
return 0;
|
|
}
|
|
return 1;
|