Blame SOURCES/nfs-utils-1.3.0-exportfs-bufsiz.patch

e19a30
diff -up nfs-utils-1.3.0/utils/exportfs/exportfs.c.orig nfs-utils-1.3.0/utils/exportfs/exportfs.c
e19a30
--- nfs-utils-1.3.0/utils/exportfs/exportfs.c.orig	2016-05-03 11:06:55.925043000 -0400
e19a30
+++ nfs-utils-1.3.0/utils/exportfs/exportfs.c	2016-05-03 11:11:58.680677000 -0400
e19a30
@@ -508,9 +508,10 @@ unexportfs(char *arg, int verbose)
e19a30
 
e19a30
 static int can_test(void)
e19a30
 {
e19a30
-	char buf[1024];
e19a30
+	char buf[1024] = { 0 };
e19a30
 	int fd;
e19a30
 	int n;
e19a30
+	size_t bufsiz = sizeof(buf);
e19a30
 
e19a30
 	fd = open("/proc/net/rpc/auth.unix.ip/channel", O_WRONLY);
e19a30
 	if (fd < 0)
e19a30
@@ -523,9 +524,9 @@ static int can_test(void)
e19a30
 	 * commit 2f74f972  (sunrpc: prepare NFS for 2038).
e19a30
 	 */
e19a30
 	if (time(NULL) > INT_TO_LONG_THRESHOLD_SECS)
e19a30
-		sprintf(buf, "nfsd 0.0.0.0 %ld -test-client-\n", LONG_MAX);
e19a30
+		snprintf(buf, bufsiz-1, "nfsd 0.0.0.0 %ld -test-client-\n", LONG_MAX);
e19a30
 	else
e19a30
-		sprintf(buf, "nfsd 0.0.0.0 %d -test-client-\n", INT_MAX);
e19a30
+		snprintf(buf, bufsiz-1, "nfsd 0.0.0.0 %d -test-client-\n", INT_MAX);
e19a30
 
e19a30
 	n = write(fd, buf, strlen(buf));
e19a30
 	close(fd);
e19a30
@@ -541,7 +542,8 @@ static int can_test(void)
e19a30
 
e19a30
 static int test_export(char *path, int with_fsid)
e19a30
 {
e19a30
-	char buf[1024];
e19a30
+	/* beside max path, buf size should take protocol str into account */
e19a30
+	char buf[NFS_MAXPATHLEN+1+64] = { 0 };
e19a30
 	char *bp = buf;
e19a30
 	int len = sizeof(buf);
e19a30
 	int fd, n;
e19a30
@@ -766,7 +768,8 @@ dumpopt(char c, char *fmt, ...)
e19a30
 static void
e19a30
 dump(int verbose, int export_format)
e19a30
 {
e19a30
-	char buf[1024];
e19a30
+	/* buf[] size should >= sizeof(struct exportent->e_path) */
e19a30
+	char buf[NFS_MAXPATHLEN+1] = { 0 };
e19a30
 	char *bp;
e19a30
 	int len;
e19a30
 	nfs_export	*exp;