[dovecot-cvs] dovecot/src/lib utc-mktime.c,1.2,1.3
cras at procontrol.fi
cras at procontrol.fi
Sat Aug 2 21:38:17 EEST 2003
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv3979/src/lib
Modified Files:
utc-mktime.c
Log Message:
utc_mktime() crashed with 64bit time_t if gmtime() didn't like >32bit values
Index: utc-mktime.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/utc-mktime.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- utc-mktime.c 24 Oct 2002 00:17:28 -0000 1.2
+++ utc-mktime.c 2 Aug 2003 17:38:15 -0000 1.3
@@ -84,6 +84,7 @@
** would still be very reasonable).
*/
+#include "lib.h"
#include "utc-mktime.h"
static int tmcomp(register const struct tm * const atmp,
@@ -116,8 +117,9 @@
** (this works regardless of whether time_t is
** signed or unsigned, though lint complains if unsigned).
*/
- for (bits = 0, t = 1; t > 0; ++bits, t <<= 1)
- ;
+ for (bits = 0, t = 1; t > 0 && bits < TIME_T_MAX_BITS-1; bits++)
+ t <<= 1;
+
/*
** If time_t is signed, then 0 is the median value,
** if time_t is unsigned, then 1 << bits is median.
More information about the dovecot-cvs
mailing list