Outlook 2002 vs. Cyrus 2.1.12

Lawrence Greenfield leg+ at andrew.cmu.edu
Mon Feb 10 14:52:51 EST 2003


   From: Fritz Test <Fritz.Test at bam.de>
   Date: 09 Feb 2003 11:25:37 +0100
[...]
   With help of the analysis of Jeremy (Thanks) I patched the function
   mkgmtime, such that it works for me now. The problem is, that gmtime(&t)
   returns a null pointer for my 64-bit system if t is out of some range. I
   don't know exactly what range, but I assume that the generated value for
   the year must fit in 32 bits?.

Your patch wouldn't work on a system with an unsigned 64-bit time_t.
(The median value would start out very large, and the binary search
would never subtract enough to get down into "normal" time.)

It seems to me that moving 
     if (bits > 40) { bits = 40; }

to above the

     t = (t < 0) ? 0 : ((time_t) 1 << bits);

would fix the problem.

Is my analysis correct?

Larry

   Here's a snipped of my code in mkgmtime.c

   -----------------------------------------------

     /*
     ** If time_t is signed, then 0 is the median value,
     ** if time_t is unsigned, then 1 << bits is median.
     */
     t = (t < 0) ? 0 : ((time_t) 1 << bits)
	;

     /* Patch begin */
     /* 
     ** On my 32-bit Debian GNU/Linux 3.0 AMD K6 PC, the algorithm
     ** converges in a range 
     ** from
     **              1901-12-13 20:46:00 GMT -> -2147483640
     ** to 
     **              2038-01-19 03:14:07 GMT ->  2147483647 
     */

     /* 
     ** It segfaults on RedHat 7.2/Alpha if bits > 56, since gmtime (&t) 
     ** returns null pointer.
     ** Hence, set bits to a resonable value <= 56.
     **
     ** Setting, e.g. bits=40, the algorithm converges in a range 
     ** from
     **            -32873-11-12 23:24:00 GMT -> -1099511627760
     ** to 
     **             36812-02-20 00:36:59 GMT ->  1099511627819
     */
     if (bits > 40) {
       bits = 40;
     }
     /* patch end */

     for ( ; ; ) {

       prt (t);
       fprintf (stderr, " ");






More information about the Info-cyrus mailing list