diff options
author | Eric Sandeen <sandeen@redhat.com> | 2011-09-16 15:49:38 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-16 19:55:55 -0400 |
commit | fe65f1ecfc501b2470a20cfd9d07f4c9efa520d2 (patch) | |
tree | bc0a37e37c9447697dd4f516f55e042dc5d538cd /e2fsck/dirinfo.c | |
parent | c3ecabe61d075efa1b3f451964f85f3157307f8d (diff) | |
download | e2fsprogs-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 'e2fsck/dirinfo.c')
-rw-r--r-- | e2fsck/dirinfo.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c index ace5b4d8..ca73c31f 100644 --- a/e2fsck/dirinfo.c +++ b/e2fsck/dirinfo.c @@ -62,6 +62,10 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs) uuid_unparse(ctx->fs->super->s_uuid, uuid); sprintf(db->tdb_fn, "%s/%s-dirinfo-XXXXXX", tdb_dir, uuid); fd = mkstemp(db->tdb_fn); + if (fd < 0) { + db->tdb = NULL; + return; + } db->tdb = tdb_open(db->tdb_fn, 0, TDB_CLEAR_IF_FIRST, O_RDWR | O_CREAT | O_TRUNC, 0600); close(fd); |