summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-02-09 19:52:33 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-02-09 19:52:33 +0000
commitc34afd9ddfabd60f5b942e218e0e656e04627709 (patch)
treebfecb061c0e2e2c39a1ad9893361f40b68165347 /sbin
parentf62a80883d8cd6622cdedf4e057454ed507684eb (diff)
fix a fd leak that happens whe checking multiple file systems and some
of them are clean. ok pedro@ millert@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/main.c13
-rw-r--r--sbin/fsck_ffs/setup.c6
2 files changed, 14 insertions, 5 deletions
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 989a0de1789..bd79485a2ef 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.28 2007/02/08 19:02:23 otto Exp $ */
+/* $OpenBSD: main.c,v 1.29 2007/02/09 19:52:32 otto Exp $ */
/* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#else
-static const char rcsid[] = "$OpenBSD: main.c,v 1.28 2007/02/08 19:02:23 otto Exp $";
+static const char rcsid[] = "$OpenBSD: main.c,v 1.29 2007/02/09 19:52:32 otto Exp $";
#endif
#endif /* not lint */
@@ -193,7 +193,16 @@ checkfilesys(char *filesys, char *mntpt, long auxdata, int child)
case 0:
if (preen)
pfatal("CAN'T CHECK FILE SYSTEM.");
+ /* FALLTHROUGH */
case -1:
+ if (fsreadfd != -1) {
+ (void)close(fsreadfd);
+ fsreadfd = -1;
+ }
+ if (fswritefd != -1) {
+ (void)close(fswritefd);
+ fswritefd = -1;
+ }
return (0);
}
info_filesys = filesys;
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index cfedf438988..12701c7899b 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setup.c,v 1.25 2007/02/08 19:02:23 otto Exp $ */
+/* $OpenBSD: setup.c,v 1.26 2007/02/09 19:52:32 otto Exp $ */
/* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.5 (Berkeley) 11/23/94";
#else
-static const char rcsid[] = "$OpenBSD: setup.c,v 1.25 2007/02/08 19:02:23 otto Exp $";
+static const char rcsid[] = "$OpenBSD: setup.c,v 1.26 2007/02/09 19:52:32 otto Exp $";
#endif
#endif /* not lint */
@@ -81,7 +81,7 @@ setup(char *dev)
u_int64_t maxfilesize;
havesb = 0;
- fswritefd = -1;
+ fswritefd = fsreadfd = -1;
doskipclean = skipclean;
if (stat(dev, &statb) < 0) {
printf("Can't stat %s: %s\n", dev, strerror(errno));