summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2016-03-15 19:50:47 +0000
committermillert <millert@openbsd.org>2016-03-15 19:50:47 +0000
commitfcefcf04fea3feebdff410a786236e0f59f3b13f (patch)
treeed9f26300c6219116f66626109e7dd46f25efd43
parentremind people rewind is seldom a good choice (diff)
downloadwireguard-openbsd-fcefcf04fea3feebdff410a786236e0f59f3b13f.tar.xz
wireguard-openbsd-fcefcf04fea3feebdff410a786236e0f59f3b13f.zip
Don't warn about valid time zone abbreviations. POSIX through 2000
says that an abbreviation cannot start with ':', and cannot contain ',', '-', '+', NUL, or a digit. POSIX from 2001 on changes this rule to say that an abbreviation can contain only '-', '+', and alphanumeric characters from the portable character set in the current locale. To be portable to both sets of rules, an abbreviation must therefore use only ASCII letters." Adapted from tzcode2015f. OK deraadt@ mestre@
-rw-r--r--usr.sbin/zdump/zdump.c26
-rw-r--r--usr.sbin/zic/zic.c21
2 files changed, 13 insertions, 34 deletions
diff --git a/usr.sbin/zdump/zdump.c b/usr.sbin/zdump/zdump.c
index 9fc235a5dde..0821934b8d5 100644
--- a/usr.sbin/zdump/zdump.c
+++ b/usr.sbin/zdump/zdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zdump.c,v 1.13 2016/03/14 15:29:29 mestre Exp $ */
+/* $OpenBSD: zdump.c,v 1.14 2016/03/15 19:50:48 millert Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2009-05-17 by Arthur David Olson.
@@ -76,24 +76,16 @@ abbrok(const char * const abbrp, const char * const zone)
return;
cp = abbrp;
wp = NULL;
- while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp))
+ while (isascii((unsigned char)*cp) &&
+ (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+'))
++cp;
- if (cp - abbrp == 0)
- wp = "lacks alphabetic at start";
- else if (cp - abbrp < 3)
- wp = "has fewer than 3 alphabetics";
+ if (cp - abbrp < 3)
+ wp = "has fewer than 3 characters";
else if (cp - abbrp > 6)
- wp = "has more than 6 alphabetics";
- if (wp == NULL && (*cp == '+' || *cp == '-')) {
- ++cp;
- if (isascii((unsigned char) *cp) &&
- isdigit((unsigned char) *cp))
- if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
- ++cp;
- if (*cp != '\0')
- wp = "differs from POSIX standard";
- }
- if (wp == NULL)
+ wp = "has more than 6 characters";
+ else if (*cp)
+ wp = "has characters other than ASCII alphanumerics, '-' or '+'";
+ else
return;
fflush(stdout);
fprintf(stderr, "%s: warning: zone \"%s\" abbreviation \"%s\" %s\n",
diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c
index a63a1c5704c..5839641e0fb 100644
--- a/usr.sbin/zic/zic.c
+++ b/usr.sbin/zic/zic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zic.c,v 1.21 2015/10/16 22:53:32 deraadt Exp $ */
+/* $OpenBSD: zic.c,v 1.22 2016/03/15 19:50:47 millert Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -2475,28 +2475,15 @@ newabbr(const char *string)
const char * cp;
char * wp;
- /*
- ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics
- ** optionally followed by a + or - and a number from 1 to 14.
- */
cp = string;
wp = NULL;
while (isascii((unsigned char)*cp) &&
- isalpha((unsigned char)*cp))
+ (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+'))
++cp;
- if (cp - string == 0)
- wp = "time zone abbreviation lacks alphabetic at start";
if (noise && cp - string > 3)
- wp = "time zone abbreviation has more than 3 alphabetics";
+ wp = "time zone abbreviation has more than 3 characters";
if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
- wp = "time zone abbreviation has too many alphabetics";
- if (wp == NULL && (*cp == '+' || *cp == '-')) {
- ++cp;
- if (isascii((unsigned char)*cp) &&
- isdigit((unsigned char)*cp))
- if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
- ++cp;
- }
+ wp = "time zone abbreviation has too many characters";
if (*cp != '\0')
wp = "time zone abbreviation differs from POSIX standard";
if (wp != NULL) {