This patch modifies all tests in the ftest directory to  use
MAXPATHLEN on all character arrays that store path/file names rather
than arbitrarily sized arrays. This corrects issues where there was
truncation happening when copying a path from one array to another if
the path was long enough. The ftest code may delete the tmp directory
instead of the tmp file due to truncation, and cause LTP to report a
failure/warning when the tmp directory disappears. We saw this in
ftest03,07 where it was trying to copy wdbuf[MAXPATHLEN] into fuss[40]
here:

    sprintf(fuss, "%s/ftest03.%d", getcwd(wdbuf, sizeof( wdbuf)), getpid());

and then attempting to delete the file but instead got the directory here:

    execl("/bin/rm", "rm", "-rf", fuss, NULL);


Signed-off-by: Henry Yei <[email protected]>


Henry Yei <[email protected]>
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest01.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest01.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest01.c	2010-08-03 16:49:44.821481701 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest01.c	2010-08-13 16:11:03.589979727 -0700
@@ -90,8 +90,8 @@ static int parent_pid;
 static int pidlist[MAXCHILD];
 static char test_name[2];
 
-static char fuss[40];         /* directory to do this in */
-static char homedir[200];     /* where we started */
+static char fuss[MAXPATHLEN];         /* directory to do this in */
+static char homedir[MAXPATHLEN];     /* where we started */
 
 static int local_flag;
 
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest02.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest02.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest02.c	2010-04-30 14:57:04.000000000 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest02.c	2010-08-13 16:11:00.721481380 -0700
@@ -258,7 +258,7 @@ char	crmsg[] = "Gee, let's write somethi
 static void crfile(int me, int count)
 {
 	int fd, val;
-	char fname[128], buf[128];
+	char fname[MAXPATHLEN], buf[MAXPATHLEN];
 
 	ft_mkname(fname, dirname, me, count);
 
@@ -297,7 +297,7 @@ static void unlfile(int me, int count)
 {
 	int	i;
 	int	val;
-	char	fname[128];
+	char	fname[MAXPATHLEN];
 
 	i = count - 10;
 
@@ -324,7 +324,7 @@ static void unlfile(int me, int count)
 static void fussdir(int me, int count)
 {
 	int val;
-	char dir[128], fname[128], savedir[128];
+	char dir[MAXPATHLEN], fname[MAXPATHLEN], savedir[MAXPATHLEN];
 
 	ft_mkname(dir, dirname, me, count);
 	rmdir(dir);
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest03.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest03.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest03.c	2010-08-03 16:49:44.821481701 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest03.c	2010-08-13 16:09:11.705481548 -0700
@@ -96,8 +96,8 @@ static int parent_pid;
 static int pidlist[MAXCHILD];
 static char test_name[2];     /* childs test directory name */
 
-static char fuss[40];         /* directory to do this in */
-static char homedir[200];     /* where we started */
+static char fuss[MAXPATHLEN];         /* directory to do this in */
+static char homedir[MAXPATHLEN];     /* where we started */
 
 static int local_flag;
 
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest04.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest04.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest04.c	2010-04-30 14:57:04.000000000 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest04.c	2010-08-13 16:09:41.697483587 -0700
@@ -78,7 +78,7 @@ static int nwait;
 static int parent_pid;
 static int pidlist[MAXCHILD];
 
-static char filename[128];
+static char filename[MAXPATHLEN];
 
 static int local_flag;
 
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest05.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest05.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest05.c	2010-08-03 16:49:44.821481701 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest05.c	2010-08-13 16:09:11.701479731 -0700
@@ -94,8 +94,8 @@ static int parent_pid;
 static int pidlist[MAXCHILD];
 static char test_name[2];     /* childs test directory name */
 
-static char fuss[40];         /* directory to do this in */
-static char homedir[200];     /* where we started */
+static char fuss[MAXPATHLEN];         /* directory to do this in */
+static char homedir[MAXPATHLEN];     /* where we started */
 
 static int local_flag;
 
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest06.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest06.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest06.c	2010-04-30 14:57:04.000000000 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest06.c	2010-08-13 16:11:00.717481554 -0700
@@ -281,8 +281,8 @@ static void crfile(int me, int count)
 	int	fd;
 	off64_t seekval;
 	int	val;
-	char	fname[128];
-	char	buf[128];
+	char	fname[MAXPATHLEN];
+	char	buf[MAXPATHLEN];
 
 	ft_mkname(fname, dirname, me, count);
 
@@ -320,7 +320,7 @@ static void crfile(int me, int count)
 static void unlfile(int me, int count)
 {
 	int val, i;
-	char fname[128];
+	char fname[MAXPATHLEN];
 
 	i = count - 10;
 	if (i < 0)
@@ -345,7 +345,7 @@ static void unlfile(int me, int count)
 static void fussdir(int me, int count)
 {
 	int val;
-	char dir[128], fname[128], savedir[128];
+	char dir[MAXPATHLEN], fname[MAXPATHLEN], savedir[MAXPATHLEN];
 
 	ft_mkname(dir, dirname, me, count);
 	rmdir(dir);
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest07.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest07.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest07.c	2010-08-03 16:49:44.821481701 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest07.c	2010-08-13 16:09:11.765479606 -0700
@@ -102,8 +102,8 @@ static int parent_pid;
 static int pidlist[MAXCHILD];
 static char test_name[2];     /* childs test directory name */
 
-static char fuss[40];         /* directory to do this in */
-static char homedir[200];     /* where we started */
+static char fuss[MAXPATHLEN];         /* directory to do this in */
+static char homedir[MAXPATHLEN];     /* where we started */
 
 static int local_flag;
 
diff -Nurp ltp-dev/testcases/kernel/fs/ftest/ftest08.c ltp-dev-wdir/testcases/kernel/fs/ftest/ftest08.c
--- ltp-dev/testcases/kernel/fs/ftest/ftest08.c	2010-04-30 15:33:10.000000000 -0700
+++ ltp-dev-wdir/testcases/kernel/fs/ftest/ftest08.c	2010-08-13 16:09:41.693481305 -0700
@@ -86,7 +86,7 @@ static int nwait;
 static int parent_pid;
 static int pidlist[MAXCHILD];
 
-static char	filename[128];
+static char	filename[MAXPATHLEN];
 static int	local_flag;
 
 int main(int ac, char *av[])
------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to