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/testcases/kernel/syscalls/mount/mount02.c
===================================================================
--- ltp.orig/testcases/kernel/syscalls/mount/mount02.c
+++ ltp/testcases/kernel/syscalls/mount/mount02.c
@@ -410,8 +410,8 @@ int 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/testcases/kernel/syscalls/mount/mount03.c
===================================================================
--- ltp.orig/testcases/kernel/syscalls/mount/mount03.c
+++ ltp/testcases/kernel/syscalls/mount/mount03.c
@@ -169,18 +169,20 @@ int 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));
 	}
 
