summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/util.c
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2006-10-11 22:00:23 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2006-10-11 22:00:23 +0000
commite8492927709c545277d0d9cd29eefa9e59813e34 (patch)
tree681b56c8d48b37a4de0a77f6426d9716ebac675c /usr.bin/cvs/util.c
parent76e3d2b471dfed803643f2a6c92dcbc4975914c9 (diff)
check fgets(3) return value and also fix a
buf[strlen(buf) - 1] = something; misuse. ok niallo@, cloder@
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r--usr.bin/cvs/util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 5e44155688a..ae322f862b0 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.90 2006/07/09 01:47:20 joris Exp $ */
+/* $OpenBSD: util.c,v 1.91 2006/10/11 22:00:22 thib Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -694,9 +694,10 @@ cvs_mkpath(const char *path)
if (cvs_cmdop == CVS_OP_UPDATE) {
if ((fp = fopen(CVS_PATH_REPOSITORY, "r")) != NULL) {
- fgets(repo, sizeof(repo), fp);
- if (repo[strlen(repo) - 1] == '\n')
- repo[strlen(repo) - 1] = '\0';
+ if ((fgets(repo, sizeof(repo), fp)) == NULL)
+ fatal("cvs_mkpath: bad repository file");
+ if ((len = strlen(repo)) && repo[len - 1] == '\n')
+ repo[len - 1] = '\0';
(void)fclose(fp);
}
}