summaryrefslogtreecommitdiffstats
path: root/usr.bin/rcs
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2014-09-30 11:01:20 +0000
committerotto <otto@openbsd.org>2014-09-30 11:01:20 +0000
commit5a71331767b94c0f6116329d01db5f7ba92b9606 (patch)
treef549b5866449680f055446d5f42d7c9f313708cf /usr.bin/rcs
parentprevent dmesg spam from some new windows-only keys found on very new (diff)
downloadwireguard-openbsd-5a71331767b94c0f6116329d01db5f7ba92b9606.tar.xz
wireguard-openbsd-5a71331767b94c0f6116329d01db5f7ba92b9606.zip
atoi to strtonum; from Fritjof Bornebusch; ok nicm@
Diffstat (limited to 'usr.bin/rcs')
-rw-r--r--usr.bin/rcs/rcstime.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/rcs/rcstime.c b/usr.bin/rcs/rcstime.c
index d1a72b5893e..290086c6da9 100644
--- a/usr.bin/rcs/rcstime.c
+++ b/usr.bin/rcs/rcstime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcstime.c,v 1.4 2014/04/29 07:44:19 jsg Exp $ */
+/* $OpenBSD: rcstime.c,v 1.5 2014/09/30 11:01:20 otto Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -36,6 +36,7 @@ rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb)
int tzone;
int pos;
char *h, *m;
+ const char *errstr;
struct tm *ltb;
time_t now;
@@ -62,8 +63,8 @@ rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb)
memcpy(tb, &rdp->rd_date, sizeof(*tb));
- tzone = atoi(h);
- if ((tzone >= 24) || (tzone <= -24))
+ tzone = strtonum(h, -23, 23, &errstr);
+ if (errstr)
errx(1, "%s: not a known time zone", tz);
if (pos) {
@@ -78,9 +79,9 @@ rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb)
tb->tm_hour = 0;
if (m != NULL) {
- tzone = atoi(m);
- if (tzone >= 60)
- errx(1, "%s: not a known time zone", tz);
+ tzone = strtonum(m, 0, 59, &errstr);
+ if (errstr)
+ errx(1, "%s: not a known minute", m);
if ((tb->tm_min + tzone) >= 60) {
tb->tm_hour++;