@@ -9,18 +9,37 @@
*
* Test for EFAULT error.
*
- * - gettimeofday fail with EFAULT when one of tv or tz pointed outside the accessible
+ * - gettimeofday fail with EFAULT when tv pointed outside the accessible
+ * address space
+ * - gettimeofday fail with EFAULT when tz pointed outside the accessible
+ * address space
+ * - gettimeofday fail with EFAULT when both tv and tz pointed outside the accessible
* address space
*/
#include "tst_test.h"
#include "lapi/syscalls.h"
-static void verify_gettimeofday(void)
+static struct timeval tv1;
+
+static struct tcase {
+ void *tv;
+ void *tz;
+} tcases[] = {
+ /* timezone structure is obsolete, tz should be treated as null */
+ {(void *)-1, NULL},
+ {&tv1, (void *)-1},
+ {(void *)-1, (void *)-1},
+};
+
+static void verify_gettimeofday(unsigned int n)
{
- TST_EXP_FAIL(tst_syscall(__NR_gettimeofday, (void *)-1, (void *)-1), EFAULT);
+ struct tcase *tc = &tcases[n];
+
+ TST_EXP_FAIL(tst_syscall(__NR_gettimeofday, tc->tv, tc->tz), EFAULT);
}
static struct tst_test test = {
- .test_all = verify_gettimeofday,
+ .tcnt = ARRAY_SIZE(tcases),
+ .test = verify_gettimeofday,
};
man-pages said that one of TV or tz pointed outside the accessible address space. Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- .../syscalls/gettimeofday/gettimeofday01.c | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-)