summaryrefslogtreecommitdiff
path: root/usr.sbin/zdump
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-03-15 19:50:49 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-03-15 19:50:49 +0000
commit5e8e83786b57ae87425ce2c11e889c05a36434bb (patch)
tree79d7288d9d17654175e9749240642eec811db7af /usr.sbin/zdump
parent7b3bf36e3577f0f232fafb3de63a661a2edc8f9d (diff)
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@
Diffstat (limited to 'usr.sbin/zdump')
-rw-r--r--usr.sbin/zdump/zdump.c26
1 files changed, 9 insertions, 17 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",