diff options
author | asomers <asomers@FreeBSD.org> | 2016-11-18 22:28:57 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-11-18 22:28:57 +0000 |
commit | 99d5e08d9d0e066585a4c9c8efe62d2138514fd2 (patch) | |
tree | d107dfe6754a9c9484a4d520137d8b6dc260b913 /usr.sbin/pw | |
parent | 01d99faedd3455353cd536056c4aeb3f97086cc0 (diff) | |
download | FreeBSD-src-99d5e08d9d0e066585a4c9c8efe62d2138514fd2.zip FreeBSD-src-99d5e08d9d0e066585a4c9c8efe62d2138514fd2.tar.gz |
MFC r307752
Close some file descriptor leaks in pw
Diffstat (limited to 'usr.sbin/pw')
-rw-r--r-- | usr.sbin/pw/grupd.c | 3 | ||||
-rw-r--r-- | usr.sbin/pw/pw_nis.c | 3 | ||||
-rw-r--r-- | usr.sbin/pw/pwupd.c | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c index 9cbe0cb..38d5e5b 100644 --- a/usr.sbin/pw/grupd.c +++ b/usr.sbin/pw/grupd.c @@ -34,6 +34,7 @@ static const char rcsid[] = #include <libutil.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "pwupd.h" @@ -73,8 +74,10 @@ gr_update(struct group * grp, char const * group) } if (gr_copy(pfd, tfd, gr, old_gr) == -1) { gr_fini(); + close(tfd); err(1, "gr_copy()"); } + close(tfd); if (gr_mkdb() == -1) { gr_fini(); err(1, "gr_mkdb()"); diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c index 6cc361b..35b26ea 100644 --- a/usr.sbin/pw/pw_nis.c +++ b/usr.sbin/pw/pw_nis.c @@ -34,6 +34,7 @@ static const char rcsid[] = #include <err.h> #include <pwd.h> #include <libutil.h> +#include <unistd.h> #include "pw.h" @@ -63,8 +64,10 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user) } if (pw_copy(pfd, tfd, pw, old_pw) == -1) { pw_fini(); + close(tfd); err(1, "pw_copy()"); } + close(tfd); if (chmod(pw_tempname(), 0644) == -1) err(1, "chmod()"); if (rename(pw_tempname(), path) == -1) diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c index ee23952..3bcb95f 100644 --- a/usr.sbin/pw/pwupd.c +++ b/usr.sbin/pw/pwupd.c @@ -111,8 +111,10 @@ pw_update(struct passwd * pwd, char const * user) } if (pw_copy(pfd, tfd, pw, old_pw) == -1) { pw_fini(); + close(tfd); err(1, "pw_copy()"); } + close(tfd); /* * in case of deletion of a user, the whole database * needs to be regenerated |