summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-09-16 15:49:38 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-09-16 19:55:55 -0400
commitfe65f1ecfc501b2470a20cfd9d07f4c9efa520d2 (patch)
treebc0a37e37c9447697dd4f516f55e042dc5d538cd /misc
parentc3ecabe61d075efa1b3f451964f85f3157307f8d (diff)
downloade2fsprogs-fe65f1ecfc501b2470a20cfd9d07f4c9efa520d2.tar.gz
e2fsprogs: Don't try to close an fd which is negative
These reflect either file descriptors which aren't tested for failure, or closures of fd's which may have failed. In setup_tdb(), test for failure of mkstemp and return without trying to open the file (again). In reserve_stdio_fds, rather than closing the "extra" fd == 3 due to the way the loop is written, just don't go that far by using while (fd <= 2). In logsave, it forks and retries forever if open fails, but at least make coverity happy by explicitly not trying to close a negative file descriptor. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r--misc/logsave.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/misc/logsave.c b/misc/logsave.c
index 74e09f7f..17457a5f 100644
--- a/misc/logsave.c
+++ b/misc/logsave.c
@@ -325,7 +325,8 @@ int main(int argc, char **argv)
write_all(outfd, outbuf, outbufsize);
free(outbuf);
}
- close(outfd);
+ if (outfd >= 0)
+ close(outfd);
exit(rc);
}