Signaled to death by 11

Rob Siemborski rjs3 at andrew.cmu.edu
Wed Mar 26 11:13:08 EST 2003


On Wed, 26 Mar 2003, Jeremy Rumpf wrote:

> Actually, I think someone a while ago had come up with a solution. I'm not
> sure how proper it is, you can decide. Here's a copy of the post from Fritz
> Test <Fritz.Test at bam.de> :
[snip]

Hmmm, I probably should have looked at it then... but I don't think this
is as correct as just checking the result of gmtime() directly for if it
is NULL or not (and then testing the result of mkgmtime, of course).

What are opinions on this patch?

Note that I suspect this will only stop cyrus from crashing, I don't think
this will actually result in "correct" behavior, since it seems that the
gmtime() implementation on systems with a 64 bit time_t is broken.  (I'm
not comfortable with an arbitrary limit on the size of a time_t just to
get around this, though).

Index: imap/imapd.c
===================================================================
RCS file: /afs/andrew.cmu.edu/system/cvs/src/cyrus/imap/imapd.c,v
retrieving revision 1.425
diff -u -r1.425 imapd.c
--- imap/imapd.c	13 Feb 2003 20:15:24 -0000	1.425
+++ imap/imapd.c	26 Mar 2003 15:48:14 -0000
@@ -6755,6 +6755,7 @@
     struct tm tm;
     int old_format = 0;
     char month[4], zone[4], *p;
+    time_t tmp_gmtime;
     int zone_off;

     memset(&tm, 0, sizeof tm);
@@ -6924,7 +6925,11 @@
     c = prot_getc(imapd_in);

     tm.tm_isdst = -1;
-    *date = mkgmtime(&tm) - zone_off*60;
+
+    tmp_gmtime = mkgmtime(&tm);
+    if(tmp_gmtime == -1) goto baddate;
+
+    *date = tmp_gmtime - zone_off*60;

     return c;

Index: lib/mkgmtime.c
===================================================================
RCS file: /afs/andrew.cmu.edu/system/cvs/src/cyrus/lib/mkgmtime.c,v
retrieving revision 1.6
diff -u -r1.6 mkgmtime.c
--- lib/mkgmtime.c	13 Feb 2003 20:15:41 -0000	1.6
+++ lib/mkgmtime.c	26 Mar 2003 15:52:20 -0000
@@ -135,6 +135,9 @@
 	t = (t < 0) ? 0 : ((time_t) 1 << bits);
 	for ( ; ; ) {
 		mytm = gmtime(&t);
+
+		if(!mytm) return WRONG;
+
 		dir = tmcomp(mytm, &yourtm);
 		if (dir != 0) {
 			if (bits-- < 0)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rob Siemborski * Andrew Systems Group * Cyert Hall 207 * 412-268-7456
Research Systems Programmer * /usr/contributed Gatekeeper





More information about the Info-cyrus mailing list