FW: better overflow check

Olson, Arthur David (NIH/NCI) olsona at dc37a.nci.nih.gov
Fri Jul 25 14:18:42 UTC 2003


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 at redhat.com]
Sent: Thursday, July 24, 2003 8:53 PM
To: tz at 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-----



More information about the tz mailing list