[fedfs-utils] [PATCH 7/7] libjunction: fedfs_save_mode() leaks an open file descriptor
Chuck Lever
chuck.lever at oracle.com
Thu Nov 3 08:29:14 PDT 2011
Make sure the file descriptor opened by fedfs_open_path() is closed
before fedfs_save_mode() returns. This bug would cause a leaked
open file descriptor for every junction created by rpc.fedfsd.
Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---
src/libjunction/junction.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/libjunction/junction.c b/src/libjunction/junction.c
index 73aa779..fa5fa7b 100644
--- a/src/libjunction/junction.c
+++ b/src/libjunction/junction.c
@@ -657,8 +657,10 @@ fedfs_save_mode(const char *pathname)
(void)snprintf(buf, sizeof(buf), "%o", ALLPERMS & stb.st_mode);
- return fedfs_set_xattr(fd, pathname, FEDFSD_XATTR_NAME_MODE,
- buf, strlen(buf));
+ retval = fedfs_set_xattr(fd, pathname, FEDFSD_XATTR_NAME_MODE,
+ buf, strlen(buf));
+ (void)close(fd);
+ return retval;
}
/**
More information about the fedfs-utils-devel
mailing list