Author: guo.hongruan@gulessoft.com
Description: The memory space allocated by malloc for storing Fstype(e.g: ext2) is not enough to include the '\0' termination character, which will cause the Fstype is undetermined and mount(2) always failed.
Index: ltp-base-header/testcases/kernel/syscalls/mount/mount02.c
===================================================================
--- ltp-base-header.orig/testcases/kernel/syscalls/mount/mount02.c
+++ ltp-base-header/testcases/kernel/syscalls/mount/mount02.c
@@ -414,8 +414,8 @@ cleanup_test(int i)
 		if (Tflag) {
 			/* Avoid buffer overflow */
 			strncpy(Type, fstype,
-		   		(FSTYPE_LEN < strlen(fstype)) ? FSTYPE_LEN :
-				 strlen(fstype));
+		   		(FSTYPE_LEN < strlen(fstype)+1) ? FSTYPE_LEN :
+				 strlen(fstype)+1);
 		} else {
 			strcpy(Type, "ext2");
 		}
Index: ltp-base-header/testcases/kernel/syscalls/mount/mount03.c
===================================================================
--- ltp-base-header.orig/testcases/kernel/syscalls/mount/mount03.c
+++ ltp-base-header/testcases/kernel/syscalls/mount/mount03.c
@@ -170,18 +170,20 @@ main(int ac, char **av)
 	}
 
 	if (Tflag) {
-		Fstype = (char *) malloc(strlen(fstype));
+		Fstype = (char *) malloc(strlen(fstype)+1);
 		if (Fstype == NULL) {
 			tst_brkm(TBROK, NULL, "malloc failed to alloc %d errno "
-				 " %d ", strlen(fstype), errno);
+				 " %d ", strlen(fstype)+1, errno);
 		}
+		memset(Fstype, 0, strlen(fstype)+1);
 		strncpy(Fstype, fstype, strlen(fstype));
 	} else {
-		Fstype = (char *) malloc(strlen(DEFAULT_FSTYPE));
+		Fstype = (char *) malloc(strlen(DEFAULT_FSTYPE)+1);
 		if (Fstype == NULL) {
 			tst_brkm(TBROK, NULL, "malloc failed to alloc %d errno "
-				 " %d ", strlen(fstype), errno);
+				 " %d ", strlen(fstype)+1, errno);
 		}
+		memset(Fstype, 0, strlen(DEFAULT_FSTYPE)+1);
 		strncpy(Fstype, DEFAULT_FSTYPE, strlen(DEFAULT_FSTYPE));
 	}
 
@@ -391,7 +393,7 @@ test_rwflag(int i, int cnt)
 			/* Validate MS_NOSUID flag of mount call */
 			
 			setup_uid();
-			if ((pid = fork()) == 0) {
+			if ((pid = FORK_OR_VFORK()) == 0) {
 				sprintf(file, "%ssetuid_test", Path_name);
 				if (chmod(file, SUID_MODE) != 0) {
 					tst_resm(TWARN, "chmod() failed to "
@@ -408,6 +410,7 @@ test_rwflag(int i, int cnt)
 					 strerror(TEST_ERRNO));
 				}
 				execve(file, NULL, NULL);
+				exit(-127);
 				/* NOT REACHEAD */
 			} else {
 				waitpid(pid, &status, 0);
@@ -431,7 +434,7 @@ setup_uid()
 	int pid, status;
     char command[PATH_MAX];
 
-	switch (pid = fork()) {
+	switch (pid = FORK_OR_VFORK()) {
 		case -1:
 			tst_resm(TWARN, "Unable to fork a child process"
 				 " to exec over!  Errno:%d, :%s",
