]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_nis.c
Close some file descriptor leaks in pw
[pw-darwin.git] / pw / pw_nis.c
index 6cc361b7a25c57ff27b5fe01a2edfbdc7fd646e1..35b26ea5224b55eac884a0e06cac3533f7e0e90a 100644 (file)
@@ -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)