[nfs-utils PATCH 2/5] nfsdcld: Fix a few Coverity Scan TOCTOU errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 utils/nfsdcld/legacy.c | 20 --------------------
 1 file changed, 20 deletions(-)

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;
-- 
2.25.4




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux