[nfs-utils,2/5] nfsdcld: Fix a few Coverity Scan TOCTOU errors
diff mbox series

Message ID 20200710203700.2546112-3-smayhew@redhat.com
State New
Headers show
Series
  • nfsdcld: Fix a number of Coverity Scan
Related show

Commit Message

Scott Mayhew July 10, 2020, 8:36 p.m. UTC
Calling stat() on recdirname so that we can see if it's a directory is
unnecessary anyways, since opendir() will report an error if it's not.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdcld/legacy.c | 20 --------------------
 1 file changed, 20 deletions(-)

Patch
diff mbox series

diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
index b8ea4ff..1fb74d4 100644
--- a/utils/nfsdcld/legacy.c
+++ b/utils/nfsdcld/legacy.c
@@ -50,7 +50,6 @@  legacy_load_clients_from_recdir(int *num_records)
 	struct dirent *entry;
 	char recdirname[PATH_MAX];
 	char buf[NFS4_OPAQUE_LIMIT];
-	struct stat st;
 	char *nl;
 
 	fd = open(NFSD_RECDIR_FILE, O_RDONLY);
@@ -69,15 +68,6 @@  legacy_load_clients_from_recdir(int *num_records)
 	if (!nl)
 		return;
 	*nl = '\0';
-	if (stat(recdirname, &st) < 0) {
-		xlog(D_GENERAL, "Unable to stat %s: %d", recdirname, errno);
-		return;
-	}
-	if (!S_ISDIR(st.st_mode)) {
-		xlog(D_GENERAL, "%s is not a directory: mode=0%o", recdirname
-				, st.st_mode);
-		return;
-	}
 	v4recovery = opendir(recdirname);
 	if (!v4recovery)
 		return;
@@ -126,7 +116,6 @@  legacy_clear_recdir(void)
 	struct dirent *entry;
 	char recdirname[PATH_MAX];
 	char dirname[PATH_MAX];
-	struct stat st;
 	char *nl;
 
 	fd = open(NFSD_RECDIR_FILE, O_RDONLY);
@@ -145,15 +134,6 @@  legacy_clear_recdir(void)
 	if (!nl)
 		return;
 	*nl = '\0';
-	if (stat(recdirname, &st) < 0) {
-		xlog(D_GENERAL, "Unable to stat %s: %d", recdirname, errno);
-		return;
-	}
-	if (!S_ISDIR(st.st_mode)) {
-		xlog(D_GENERAL, "%s is not a directory: mode=0%o", recdirname
-				, st.st_mode);
-		return;
-	}
 	v4recovery = opendir(recdirname);
 	if (!v4recovery)
 		return;