From: Aaron Crane Date: Mon, 4 Aug 2014 01:52:11 +0000 (-0400) Subject: debugfs: fix double-close bug in "rdump" and "dump -p" X-Git-Tag: v1.42.12~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b0662fc95e4fefb489ba332d417f0733eb37f44;p=thirdparty%2Fe2fsprogs.git debugfs: fix double-close bug in "rdump" and "dump -p" Previously, both of these usages called dump_file() with a true value as the "preserve" argument, which caused it to in turn call fix_perms() to make the permissions on the locally-dumped file match those found on the ext2 filesystem. fix_perms() then attempted to close(2) the file descriptor (if any) before returning (though it didn't attempt to report on any errors found while doing so). However, in both of these situations, the local file being dumped had been opened by the caller of dump_file(), which also closes it (and reports on any errors detected when closing). This meant that both "rdump" and "dump -p" would then emit a spurious EBADF message when trying to re-close the local file descriptor. Deleting the spurious close(2) call in fix_perms() fixes the problem in both commands. Signed-off-by: Aaron Crane Signed-off-by: Theodore Ts'o --- diff --git a/debugfs/dump.c b/debugfs/dump.c index f4f1625ff..13bf06afe 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -91,9 +91,6 @@ static void fix_perms(const char *cmd, const struct ext2_inode *inode, if (i == -1) com_err(cmd, errno, "while changing ownership of %s", name); - if (fd != -1) - close(fd); - ut.actime = inode->i_atime; ut.modtime = inode->i_mtime; if (utime(name, &ut) == -1)