diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2007-06-30 13:20:43 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2007-06-30 13:20:43 +0000 |
commit | f173f39f9f09921eba6733eccef2eca6b150491e (patch) | |
tree | 6a21cb3016f5424611a161e424251ed5f56de4c3 /lib/libc/time/zic.c | |
parent | f64de6378e5db16488e477caf5f07bc24b7a5511 (diff) |
Update to tzcode2007f from elsie.nci.nih.gov
Diffstat (limited to 'lib/libc/time/zic.c')
-rw-r--r-- | lib/libc/time/zic.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index a7218ae8aba..2ea9df1e8b4 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zic.c,v 1.28 2007/02/27 16:40:35 millert Exp $ */ +/* $OpenBSD: zic.c,v 1.29 2007/06/30 13:20:42 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -117,7 +117,7 @@ static void associate P((void)); static int ciequal P((const char * ap, const char * bp)); static void convert P((long val, char * buf)); static void convert64 P((zic_t val, char * buf)); -static void dolink P((const char * fromfile, const char * tofile)); +static void dolink P((const char * fromfield, const char * tofield)); static void doabbr P((char * abbr, size_t size, const char * format, const char * letters, int isdst, int doquotes)); static void eat P((const char * name, int num)); @@ -621,26 +621,26 @@ _("%s: More than one -L option specified\n"), } static void -dolink(fromfile, tofile) -const char * const fromfile; -const char * const tofile; +dolink(fromfield, tofield) +const char * const fromfield; +const char * const tofield; { register char * fromname; register char * toname; - if (fromfile[0] == '/') - fromname = ecpyalloc(fromfile); + if (fromfield[0] == '/') + fromname = ecpyalloc(fromfield); else { fromname = ecpyalloc(directory); fromname = ecatalloc(fromname, "/"); - fromname = ecatalloc(fromname, fromfile); + fromname = ecatalloc(fromname, fromfield); } - if (tofile[0] == '/') - toname = ecpyalloc(tofile); + if (tofield[0] == '/') + toname = ecpyalloc(tofield); else { toname = ecpyalloc(directory); toname = ecatalloc(toname, "/"); - toname = ecatalloc(toname, tofile); + toname = ecatalloc(toname, tofield); } /* ** We get to be careful here since @@ -902,7 +902,8 @@ const char * string; const char * const errstring; const int signable; { - int hh, mm, ss, sign; + long hh; + int mm, ss, sign; if (string == NULL || *string == '\0') return 0; @@ -912,27 +913,32 @@ const int signable; sign = -1; ++string; } else sign = 1; - if (sscanf(string, scheck(string, "%d"), &hh) == 1) + if (sscanf(string, scheck(string, "%ld"), &hh) == 1) mm = ss = 0; - else if (sscanf(string, scheck(string, "%d:%d"), &hh, &mm) == 2) + else if (sscanf(string, scheck(string, "%ld:%d"), &hh, &mm) == 2) ss = 0; - else if (sscanf(string, scheck(string, "%d:%d:%d"), + else if (sscanf(string, scheck(string, "%ld:%d:%d"), &hh, &mm, &ss) != 3) { error(errstring); return 0; } - if ((hh < 0 || hh >= HOURSPERDAY || + if (hh < 0 || mm < 0 || mm >= MINSPERHOUR || - ss < 0 || ss > SECSPERMIN) && - !(hh == HOURSPERDAY && mm == 0 && ss == 0)) { + ss < 0 || ss > SECSPERMIN) { error(errstring); return 0; } - if (noise && hh == HOURSPERDAY) + if (LONG_MAX / SECSPERHOUR < hh) { + error(_("time overflow")); + return 0; + } + if (noise && hh == HOURSPERDAY && mm == 0 && ss == 0) warning(_("24:00 not handled by pre-1998 versions of zic")); - return eitol(sign) * - (eitol(hh * MINSPERHOUR + mm) * - eitol(SECSPERMIN) + eitol(ss)); + if (noise && (hh > HOURSPERDAY || + (hh == HOURSPERDAY && (mm != 0 || ss != 0)))) +warning(_("values over 24 hours not handled by pre-2007 versions of zic")); + return oadd(eitol(sign) * hh * eitol(SECSPERHOUR), + eitol(sign) * (eitol(mm) * eitol(SECSPERMIN) + eitol(ss))); } static void @@ -2027,7 +2033,7 @@ const int zonecount; wp = ecpyalloc(_("no POSIX environment variable for zone")); wp = ecatalloc(wp, " "); - wp = ecatalloc(wp, zpfirst->z_name); + wp = ecatalloc(wp, zpfirst->z_name); warning(wp); ifree(wp); } @@ -2283,6 +2289,10 @@ const int ttisgmt; error(_("too many local time types")); exit(EXIT_FAILURE); } + if (! (-1L - 2147483647L <= gmtoff && gmtoff <= 2147483647L)) { + error(_("UTC offset out of range")); + exit(EXIT_FAILURE); + } gmtoffs[i] = gmtoff; isdsts[i] = isdst; ttisstds[i] = ttisstd; |