"allow_nets didn't work correctly with big endian machines."

From upstream:
http://hg.dovecot.org/dovecot-1.0/rev/71c02fdf1b59

via brad@
This commit is contained in:
bernd 2008-05-16 05:45:26 +00:00
parent b741618707
commit 2bc4609feb
2 changed files with 44 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.92 2008/04/28 09:46:07 bernd Exp $
# $OpenBSD: Makefile,v 1.93 2008/05/16 05:45:26 bernd Exp $
SHARED_ONLY= Yes
@ -10,7 +10,7 @@ V_DOVECOT= 1.0.13
V_SIEVE= 1.0.2
PKGNAME= dovecot-${V_DOVECOT}
PKGNAME-server= dovecot-${V_DOVECOT}p0
PKGNAME-server= dovecot-${V_DOVECOT}p1
PKGNAME-sieve= dovecot-sieve-${V_SIEVE}p8
DISTNAME= dovecot-${V_DOVECOT}

View File

@ -0,0 +1,42 @@
$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;