diff options
author | Andrey Borzenkov <arvidjaar@gmail.com> | 2011-03-10 17:39:02 +0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-03-10 20:48:58 +0100 |
commit | 90102b22ba0a9a6aa8ff1b9d32349e100902a8d7 (patch) | |
tree | d0e043dd677d3750b91aaaa4dd6d9a2e630429d4 /src | |
parent | 756a8d17bb106f9624736843377e7831b195fac7 (diff) |
pam: do not leak file descriptor if flock fails
If flock fails, fd is not returned to caller so it cannot clean up.
Diffstat (limited to 'src')
-rw-r--r-- | src/pam-module.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pam-module.c b/src/pam-module.c index 7f91584705..e1a1a5001c 100644 --- a/src/pam-module.c +++ b/src/pam-module.c @@ -198,8 +198,12 @@ static int open_file_and_lock(const char *fn) { * as the filesystems in question should be local, and only * locally accessible, and most likely even tmpfs. */ - if (flock(fd, LOCK_EX) < 0) - return -errno; + if (flock(fd, LOCK_EX) < 0) { + int r = -errno; + + close_nointr_nofail(fd); + return r; + } return fd; } |