diff options
author | Martin Schwenke <martin@meltin.net> | 2016-07-28 14:04:23 +1000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2016-08-10 11:24:36 +0200 |
commit | 2ffc30168e23ea037177ca929398b9a91c9134ea (patch) | |
tree | 1cb1f2ca1c3588e44d1871acf13304506a6711d6 /ctdb/server | |
parent | 96395c2e59864a51ca3f2dd6619391e64c5ef20c (diff) | |
download | samba-2ffc30168e23ea037177ca929398b9a91c9134ea.tar.gz |
ctdb-mutex: Fix CID 1359217 Resource leak (RESOURCE_LEAK)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Aug 3 09:13:55 CEST 2016 on sn-devel-144
(cherry picked from commit 24e28c0aa52399f03acf830a1ad72af0139b0606)
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_mutex_fcntl_helper.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ctdb/server/ctdb_mutex_fcntl_helper.c b/ctdb/server/ctdb_mutex_fcntl_helper.c index 93c7f6236dd..06c2205d496 100644 --- a/ctdb/server/ctdb_mutex_fcntl_helper.c +++ b/ctdb/server/ctdb_mutex_fcntl_helper.c @@ -27,7 +27,7 @@ static char *progname = NULL; -static char fcntl_lock(const char *file) +static char fcntl_lock(const char *file, int *outfd) { int fd; struct flock lock; @@ -62,6 +62,8 @@ static char fcntl_lock(const char *file) return '3'; } + *outfd = fd; + return '0'; } @@ -70,6 +72,7 @@ int main(int argc, char *argv[]) char result; int ppid; const char *file = NULL; + int fd = -1; progname = argv[0]; @@ -81,10 +84,14 @@ int main(int argc, char *argv[]) ppid = getppid(); file = argv[1]; - result = fcntl_lock(file); + result = fcntl_lock(file, &fd); sys_write(STDOUT_FILENO, &result, 1); ctdb_wait_for_process_to_exit(ppid); + if (fd != -1) { + close(fd); + } + return 0; } |