diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-09-01 15:14:51 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-09-01 15:14:51 +0000 |
commit | 7a82cf511d6d3187ef22840f5836e74a0accad0d (patch) | |
tree | f3354f4bcc7594657686b86703c019132464716d /usr.sbin | |
parent | 45bfd3158c137b39e6ee8dfb6da49e8840f41180 (diff) | |
download | src-7a82cf511d6d3187ef22840f5836e74a0accad0d.tar.gz src-7a82cf511d6d3187ef22840f5836e74a0accad0d.zip |
pw: Fix a resource leak.
Reported by: Coverity
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Notes
Notes:
svn path=/head/; revision=365045
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pw/rm_r.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.sbin/pw/rm_r.c b/usr.sbin/pw/rm_r.c index 66298a248f19..66ec3f21423f 100644 --- a/usr.sbin/pw/rm_r.c +++ b/usr.sbin/pw/rm_r.c @@ -57,6 +57,10 @@ rm_r(int rootfd, const char *path, uid_t uid) } d = fdopendir(dirfd); + if (d == NULL) { + (void)close(dirfd); + return; + } while ((e = readdir(d)) != NULL) { if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0) continue; |