chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
756a8d1
)
pam: do not leak file descriptor if flock fails
author
Andrey Borzenkov
<arvidjaar@gmail.com>
Thu, 10 Mar 2011 14:39:02 +0000
(17:39 +0300)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 10 Mar 2011 19:48:58 +0000
(20:48 +0100)
If flock fails, fd is not returned to caller so it cannot clean up.
src/pam-module.c
patch
|
blob
|
history
diff --git
a/src/pam-module.c
b/src/pam-module.c
index 7f915847052b061dd0de370aad67b615dbf36532..e1a1a5001cedc9b438a31546906511949716c703 100644
(file)
--- 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;
}