diff options
author | 2006-10-11 22:00:22 +0000 | |
---|---|---|
committer | 2006-10-11 22:00:22 +0000 | |
commit | c9ccdb9d19466177bbe9df6d6fccdd45facc33b1 (patch) | |
tree | 0414f3bc218bc77fc92cffb00658e7b4f991996f | |
parent | quotes around filename, pr 5253, sthen@zephyr.spacehopper.org (diff) | |
download | wireguard-openbsd-c9ccdb9d19466177bbe9df6d6fccdd45facc33b1.tar.xz wireguard-openbsd-c9ccdb9d19466177bbe9df6d6fccdd45facc33b1.zip |
check fgets(3) return value and also fix a
buf[strlen(buf) - 1] = something; misuse.
ok niallo@, cloder@
-rw-r--r-- | usr.bin/cvs/util.c | 9 |
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); } } |