diff mbox series

[nfs-utils,3/5] nfsdcld: Fix a few Coverity Scan STRING_NULL errors

Message ID 20200710203700.2546112-4-smayhew@redhat.com (mailing list archive)
State New, archived
Headers show
Series nfsdcld: Fix a number of Coverity Scan | expand

Commit Message

Scott Mayhew July 10, 2020, 8:36 p.m. UTC
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdcld/legacy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
index 1fb74d4..9e9f758 100644
--- a/utils/nfsdcld/legacy.c
+++ b/utils/nfsdcld/legacy.c
@@ -48,7 +48,7 @@  legacy_load_clients_from_recdir(int *num_records)
 	int fd;
 	DIR *v4recovery;
 	struct dirent *entry;
-	char recdirname[PATH_MAX];
+	char recdirname[PATH_MAX+1];
 	char buf[NFS4_OPAQUE_LIMIT];
 	char *nl;
 
@@ -64,6 +64,7 @@  legacy_load_clients_from_recdir(int *num_records)
 	}
 	close(fd);
 	/* the output from the proc file isn't null-terminated */
+	recdirname[PATH_MAX] = '\0';
 	nl = strchr(recdirname, '\n');
 	if (!nl)
 		return;
@@ -114,7 +115,7 @@  legacy_clear_recdir(void)
 	int fd;
 	DIR *v4recovery;
 	struct dirent *entry;
-	char recdirname[PATH_MAX];
+	char recdirname[PATH_MAX+1];
 	char dirname[PATH_MAX];
 	char *nl;
 
@@ -130,6 +131,7 @@  legacy_clear_recdir(void)
 	}
 	close(fd);
 	/* the output from the proc file isn't null-terminated */
+	recdirname[PATH_MAX] = '\0';
 	nl = strchr(recdirname, '\n');
 	if (!nl)
 		return;