Hi, Guys,
I think I found a bug of mount02.c and mount03.c which can not validate
mount system call correctly. I did the following change, on my sites, it
works OK. Here is the patch, hope it is useful.
Running these testcases manually can reproduce this bug:
mount02 -D /dev/hda2 -T ext2
mount03 -D /dev/hda2 -T ext2
Index: testcases/kernel/syscalls/mount/mount02.c
===================================================================
--- testcases/kernel/syscalls/mount/mount02.c (revision 297)
+++ testcases/kernel/syscalls/mount/mount02.c (working copy)
@@ -414,8 +414,8 @@
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: mount03.c
===================================================================
--- mount03.c (revision 297)
+++ mount03.c (working copy)
@@ -170,18 +170,20 @@
}
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);
}
+ 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);
}
+ memset(Fstype, 0, strlen(DEFAULT_FSTYPE)+1);
strncpy(Fstype, DEFAULT_FSTYPE, strlen(DEFAULT_FSTYPE));
}
@@ -408,6 +410,7 @@
strerror(TEST_ERRNO));
}
execve(file, NULL, NULL);
+ exit(-127);
/* NOT REACHEAD */
} else {
waitpid(pid, &status, 0);
--
Guo Hongruan, Embedded Linux Consultant
Mobile: +86-0-13484056007
Skype: camelguo
http://www.gulessoft.com
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list