summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2010-07-30 21:47:18 +0000
committerray <ray@openbsd.org>2010-07-30 21:47:18 +0000
commit092db204ab3eaa831b770cee34445d3a12641812 (patch)
tree1f007d11a2da207bc29662659568787f65912473
parentAdd "-S" to library installs to avoid breakage when one (diff)
downloadwireguard-openbsd-092db204ab3eaa831b770cee34445d3a12641812.tar.xz
wireguard-openbsd-092db204ab3eaa831b770cee34445d3a12641812.zip
Check date_parse return values.
OK xsa
-rw-r--r--usr.bin/cvs/annotate.c5
-rw-r--r--usr.bin/cvs/checkout.c5
-rw-r--r--usr.bin/cvs/diff.c8
-rw-r--r--usr.bin/cvs/getlog.c28
-rw-r--r--usr.bin/cvs/update.c15
-rw-r--r--usr.bin/rcs/ci.c8
-rw-r--r--usr.bin/rcs/co.c13
-rw-r--r--usr.bin/rcs/rlog.c26
8 files changed, 71 insertions, 37 deletions
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index ac63148c99c..b5e391f352b 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.61 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: annotate.c,v 1.62 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -69,7 +69,8 @@ cvs_annotate(int argc, char **argv)
switch (ch) {
case 'D':
dateflag = optarg;
- cvs_specified_date = date_parse(dateflag);
+ if ((cvs_specified_date = date_parse(dateflag)) == -1)
+ fatal("invalid date: %s", dateflag);
break;
case 'f':
force_head = 1;
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 1f6d3622270..3bd567275b1 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.166 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: checkout.c,v 1.167 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -95,7 +95,8 @@ cvs_checkout(int argc, char **argv)
exit(0);
case 'D':
dateflag = optarg;
- cvs_specified_date = date_parse(dateflag);
+ if ((cvs_specified_date = date_parse(dateflag)) == -1)
+ fatal("invalid date: %s", dateflag);
reset_tag = 0;
break;
case 'd':
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index a9ee2ab448f..11762ba4d69 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.158 2010/07/28 21:19:30 nicm Exp $ */
+/* $OpenBSD: diff.c,v 1.159 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
@@ -106,10 +106,12 @@ cvs_diff(int argc, char **argv)
break;
case 'D':
if (date1 == -1 && rev1 == NULL) {
- date1 = date_parse(optarg);
+ if ((date1 = date_parse(optarg)) == -1)
+ fatal("invalid date: %s", optarg);
dateflag1 = optarg;
} else if (date2 == -1 && rev2 == NULL) {
- date2 = date_parse(optarg);
+ if ((date2 = date_parse(optarg)) == -1)
+ fatal("invalid date: %s", optarg);
dateflag2 = optarg;
} else {
fatal("no more than 2 revisions/dates can"
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index 73917bc02a0..0df3887e0b2 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.94 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: getlog.c,v 1.95 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
@@ -232,9 +232,12 @@ cvs_log_local(struct cvs_file *cf)
if (logrev != NULL)
nrev = cvs_revision_select(cf->file_rcs, logrev);
- else if (logdate != NULL)
- nrev = date_select(cf->file_rcs, logdate);
- else
+ else if (logdate != NULL) {
+ if ((nrev = date_select(cf->file_rcs, logdate)) == -1) {
+ cvs_log(LP_ERR, "invalid date: %s", logdate);
+ return;
+ }
+ } else
nrev = cf->file_rcs->rf_ndelta;
cvs_printf("\nRCS file: %s", cf->file_rpath);
@@ -452,7 +455,8 @@ date_select(RCSFILE *file, char *date)
if (last == NULL) {
flags |= LDATE_SINGLE;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
delim = '\0';
last = "\0";
} else {
@@ -462,22 +466,26 @@ date_select(RCSFILE *file, char *date)
if (delim == '>' && *last == '\0') {
flags |= LDATE_EARLIER;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
}
if (delim == '>' && *first == '\0' && *last != '\0') {
flags |= LDATE_LATER;
- firstdate = date_parse(last);
+ if ((firstdate = date_parse(last)) == -1)
+ return -1;
}
if (delim == '<' && *last == '\0') {
flags |= LDATE_LATER;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
}
if (delim == '<' && *first == '\0' && *last != '\0') {
flags |= LDATE_EARLIER;
- firstdate = date_parse(last);
+ if ((firstdate = date_parse(last)) == -1)
+ return -1;
}
if (*first != '\0' && *last != '\0') {
@@ -490,6 +498,8 @@ date_select(RCSFILE *file, char *date)
firstdate = date_parse(last);
lastdate = date_parse(first);
}
+ if (firstdate == -1 || lastdate == -1)
+ return -1;
}
TAILQ_FOREACH(rdp, &(file->rf_delta), rd_list) {
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 5a0b2c78c8d..4ff5fb8eacc 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.162 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: update.c,v 1.163 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -78,7 +78,8 @@ cvs_update(int argc, char **argv)
break;
case 'D':
dateflag = optarg;
- cvs_specified_date = date_parse(dateflag);
+ if ((cvs_specified_date = date_parse(dateflag)) == -1)
+ fatal("invalid date: %s", dateflag);
reset_tag = 0;
break;
case 'd':
@@ -592,7 +593,10 @@ update_join_file(struct cvs_file *cf)
if ((p = strchr(jrev2, ':')) != NULL) {
(*p++) = '\0';
- cvs_specified_date = date_parse(p);
+ if ((cvs_specified_date = date_parse(p)) == -1) {
+ cvs_printf("invalid date: %s", p);
+ goto out;
+ }
}
rev2 = rcs_translate_tag(jrev2, cf->file_rcs);
@@ -601,7 +605,10 @@ update_join_file(struct cvs_file *cf)
if (jrev1 != NULL) {
if ((p = strchr(jrev1, ':')) != NULL) {
(*p++) = '\0';
- cvs_specified_date = date_parse(p);
+ if ((cvs_specified_date = date_parse(p)) == -1) {
+ cvs_printf("invalid date: %s", p);
+ goto out;
+ }
}
rev1 = rcs_translate_tag(jrev1, cf->file_rcs);
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 6740f665db2..e8f654ff69e 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.209 2010/07/28 09:07:11 ray Exp $ */
+/* $OpenBSD: ci.c,v 1.210 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -136,7 +136,7 @@ checkin_main(int argc, char **argv)
case 'd':
if (rcs_optarg == NULL)
pb.date = DATE_MTIME;
- else if ((pb.date = date_parse(rcs_optarg)) <= 0)
+ else if ((pb.date = date_parse(rcs_optarg)) == -1)
errx(1, "invalid date");
break;
case 'f':
@@ -994,7 +994,7 @@ checkin_parsekeyword(char *keystring, RCSNUM **rev, time_t *date,
if (i < 5)
break;
(void)xasprintf(&datestring, "%s %s", tokens[3], tokens[4]);
- if ((*date = date_parse(datestring)) <= 0)
+ if ((*date = date_parse(datestring)) == -1)
errx(1, "could not parse date");
xfree(datestring);
@@ -1021,7 +1021,7 @@ checkin_parsekeyword(char *keystring, RCSNUM **rev, time_t *date,
if (i < 3)
break;
(void)xasprintf(&datestring, "%s %s", tokens[1], tokens[2]);
- if ((*date = date_parse(datestring)) <= 0)
+ if ((*date = date_parse(datestring)) == -1)
errx(1, "could not parse date");
xfree(datestring);
break;
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 90c9e14ceca..a6860d021b2 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.112 2010/07/28 09:07:11 ray Exp $ */
+/* $OpenBSD: co.c,v 1.113 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -261,8 +261,10 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
RCSNUM *rev;
rcsdate = givendate = -1;
- if (date != NULL)
- givendate = date_parse(date);
+ if (date != NULL && (givendate = date_parse(date)) == -1) {
+ warnx("invalid date: %s", date);
+ return -1;
+ }
if (file->rf_ndelta == 0 && !(flags & QUIET))
(void)fprintf(stderr,
@@ -303,7 +305,10 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) {
if (date != NULL) {
fdate = asctime(&rdp->rd_date);
- rcsdate = date_parse(fdate);
+ if ((rcsdate = date_parse(fdate)) == -1) {
+ warnx("invalid date: %s", fdate);
+ return -1;
+ }
if (givendate <= rcsdate)
continue;
}
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index 43d451450e0..8f6ecf0874b 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.63 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: rlog.c,v 1.64 2010/07/30 21:47:18 ray Exp $ */
/*
* Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -227,7 +227,8 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
if (last == NULL) {
flags |= RLOG_DATE_SINGLE;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
delim = '\0';
last = "\0";
} else {
@@ -237,22 +238,26 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
if (delim == '>' && *last == '\0') {
flags |= RLOG_DATE_EARLIER;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
}
if (delim == '>' && *first == '\0' && *last != '\0') {
flags |= RLOG_DATE_LATER;
- firstdate = date_parse(last);
+ if ((firstdate = date_parse(last)) == -1)
+ return -1;
}
if (delim == '<' && *last == '\0') {
flags |= RLOG_DATE_LATER;
- firstdate = date_parse(first);
+ if ((firstdate = date_parse(first)) == -1)
+ return -1;
}
if (delim == '<' && *first == '\0' && *last != '\0') {
flags |= RLOG_DATE_EARLIER;
- firstdate = date_parse(last);
+ if ((firstdate = date_parse(last)) == -1)
+ return -1;
}
if (*first != '\0' && *last != '\0') {
@@ -265,6 +270,8 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
firstdate = date_parse(last);
lastdate = date_parse(first);
}
+ if (firstdate == -1 || lastdate == -1)
+ return -1;
}
TAILQ_FOREACH(rdp, &(rcsfile->rf_delta), rd_list) {
@@ -343,9 +350,10 @@ rlog_file(const char *fname, RCSFILE *file)
if (rflag == 1)
nrev = rcs_rev_select(file, revisions);
- else if (dflag == 1)
- nrev = rlog_select_daterev(file, rlog_dates);
- else
+ else if (dflag == 1) {
+ if ((nrev = rlog_select_daterev(file, rlog_dates)) == -1)
+ errx(1, "invalid date: %s", rlog_dates);
+ } else
nrev = file->rf_ndelta;
if ((workfile = basename(fname)) == NULL)