summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-04-17 16:47:47 +0000
committerderaadt <deraadt@openbsd.org>2015-04-17 16:47:47 +0000
commit788b78fc9032e594140598b6ce42e2f260db1f83 (patch)
tree1a24c51e96987217bdc20886c606317513ad9c5d
parentOn Ethernet packets have a minimal length, so very short packets (diff)
downloadwireguard-openbsd-788b78fc9032e594140598b6ce42e2f260db1f83.tar.xz
wireguard-openbsd-788b78fc9032e594140598b6ce42e2f260db1f83.zip
FALLTHROUGH in getopt is incorrect. While here use strtonum
to parse tz_minuteswest. ok millert
-rw-r--r--bin/date/date.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index 8c39ac08bfd..6d12c7da2de 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: date.c,v 1.46 2015/03/17 19:31:30 millert Exp $ */
+/* $OpenBSD: date.c,v 1.47 2015/04/17 16:47:47 deraadt Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
@@ -59,6 +59,7 @@ int
main(int argc, char *argv[])
{
struct timezone tz;
+ const char *errstr;
struct tm *tp;
int ch, rflag;
char *format, buf[1024], *outzone = NULL;
@@ -87,12 +88,10 @@ main(int argc, char *argv[])
err(1, "cannot unsetenv TZ");
break;
case 't': /* minutes west of GMT */
- /* error check; don't allow "PST" */
- if (isdigit((unsigned char)*optarg)) {
- tz.tz_minuteswest = atoi(optarg);
- break;
- }
- /* FALLTHROUGH */
+ tz.tz_minuteswest = strtonum(optarg, 0, 24*60-1, &errstr);
+ if (errstr)
+ errx(1, "-t %s: %s", optarg, errstr);
+ break;
case 'z':
outzone = optarg;
break;