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

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