Ulrich Drepper is on the time zone mailing list, but at a different address than the one below. Direct replies carefully. --ado -----Original Message----- From: Ulrich Drepper [mailto:drepper@redhat.com] Sent: Thursday, July 24, 2003 8:53 PM To: tz@lecserver.nci.nih.gov Subject: better overflow check -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The code at the end of zic.c:rpytime has the comment Cheap overflow check. Indeed, cheap. And unfortunately insufficient. If the code is executed on a machine with 64 bit time_t the result differs from that you get on a machine with 32 bit time_t. The following patch does a better job. - --- timezone/zic.c 6 Apr 2002 03:39:57 -0000 1.14 +++ timezone/zic.c 25 Jul 2003 00:48:48 -0000 1.15 @@ -2152,12 +2152,13 @@ } if (dayoff < 0 && !TYPE_SIGNED(time_t)) return min_time; + if (dayoff < min_time / SECSPERDAY) + return min_time; + if (dayoff > max_time / SECSPERDAY) + return max_time; t = (time_t) dayoff * SECSPERDAY; - - /* - - ** Cheap overflow check. - - */ - - if (t / SECSPERDAY != dayoff) - - return (dayoff > 0) ? max_time : min_time; + if (t > 0 && max_time - t < rp->r_tod) + return max_time; return tadd(t, rp->r_tod); } - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/IH8K2ijCOnn/RHQRAgSOAKCGEBJ9z2ToBRnKeXzLgPDMP4m1EgCfSos7 JcgAEplXNFZy95IqU50gsFM= =mZY1 -----END PGP SIGNATURE-----
A nice catch by Ulrich. There may a similar problem in inleap, which uses a similar "cheap overflow check" (i.e., a check that looks for 64-bit overflow where perhaps a 32-bit overflow check was desired).
participants (2)
-
Olson, Arthur David (NIH/NCI) -
Paul Eggert