Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 2020 15:14:51 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r365045 - head/usr.sbin/pw
Message-ID:  <202009011514.081FEp2Q093552@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Sep  1 15:14:51 2020
New Revision: 365045
URL: https://svnweb.freebsd.org/changeset/base/365045

Log:
  pw: Fix a resource leak.
  
  Reported by:	Coverity
  MFC after:	1 week
  Sponsored by:	NetApp, Inc.
  Sponsored by:	Klara, Inc.

Modified:
  head/usr.sbin/pw/rm_r.c

Modified: head/usr.sbin/pw/rm_r.c
==============================================================================
--- head/usr.sbin/pw/rm_r.c	Tue Sep  1 15:14:26 2020	(r365044)
+++ head/usr.sbin/pw/rm_r.c	Tue Sep  1 15:14:51 2020	(r365045)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009011514.081FEp2Q093552>