summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/getlog.c
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2010-07-30 21:47:19 +0000
committerRay Lai <ray@cvs.openbsd.org>2010-07-30 21:47:19 +0000
commit5b4d08115158f975fd068894b5cfad09175bc414 (patch)
tree3e47af1712c2cd497d780fd8cee57455d23222fe /usr.bin/cvs/getlog.c
parenta3cf3598f3d68ae8538b4a7479b9286ace167aae (diff)
Check date_parse return values.
OK xsa
Diffstat (limited to 'usr.bin/cvs/getlog.c')
-rw-r--r--usr.bin/cvs/getlog.c28
1 files changed, 19 insertions, 9 deletions
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) {