From e8492927709c545277d0d9cd29eefa9e59813e34 Mon Sep 17 00:00:00 2001 From: "Thordur I. Bjornsson" Date: Wed, 11 Oct 2006 22:00:23 +0000 Subject: check fgets(3) return value and also fix a buf[strlen(buf) - 1] = something; misuse. ok niallo@, cloder@ --- usr.bin/cvs/util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'usr.bin/cvs/util.c') 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 * Copyright (c) 2005, 2006 Joris Vink @@ -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); } } -- cgit v1.2.3