dovecot-2.2: Fixed signed integer shift overflows.

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 20:57:39 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/6411d91d0755
changeset: 14669:6411d91d0755
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jun 24 02:20:28 2012 +0300
description:
Fixed signed integer shift overflows.
These didn't actually cause any broken behavior. One of these was caught by
http://embed.cs.utah.edu/ioc/ and the rest I grepped.

diffstat:

 src/director/mail-host.c |  2 +-
 src/lib/primes.c         |  2 +-
 src/lib/utc-mktime.c     |  2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 11c07ab07d39 -r 6411d91d0755 src/director/mail-host.c
--- a/src/director/mail-host.c	Fri Jun 22 18:51:42 2012 +0300
+++ b/src/director/mail-host.c	Sun Jun 24 02:20:28 2012 +0300
@@ -110,7 +110,7 @@
 	i2 = htonl(ip2_arr[i]);
 
 	for (j = last_bits; j < 32; j++) {
-		if ((i1 & (1 << j)) != (i2 & (1 << j))) {
+		if ((i1 & (1U << j)) != (i2 & (1U << j))) {
 			i_error("IP address range too large: %s-%s",
 				net_ip2addr(&ip1), net_ip2addr(&ip2));
 			return -1;
diff -r 11c07ab07d39 -r 6411d91d0755 src/lib/primes.c
--- a/src/lib/primes.c	Fri Jun 22 18:51:42 2012 +0300
+++ b/src/lib/primes.c	Sun Jun 24 02:20:28 2012 +0300
@@ -41,7 +41,7 @@
 	unsigned int i;
 
 	for (i = 31; i > PRIME_SKIP_COUNT; i--) {
-		if ((num & (1 << i)) != 0)
+		if ((num & (1U << i)) != 0)
 			return primes[i - PRIME_SKIP_COUNT];
 	}
 	return primes[0];
diff -r 11c07ab07d39 -r 6411d91d0755 src/lib/utc-mktime.c
--- a/src/lib/utc-mktime.c	Fri Jun 22 18:51:42 2012 +0300
+++ b/src/lib/utc-mktime.c	Sun Jun 24 02:20:28 2012 +0300
@@ -33,7 +33,7 @@
 #ifdef TIME_T_SIGNED
 	t = 0;
 #else
-	t = 1 << (TIME_T_MAX_BITS - 1);
+	t = (time_t)1 << (TIME_T_MAX_BITS - 1);
 #endif
 	for (bits = TIME_T_MAX_BITS - 2;; bits--) {
 		try_tm = gmtime(&t);


More information about the dovecot-cvs mailing list