From 84be84db7ba0e4cf0794cea9e83ec3e89148b120 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 13 Feb 2016 01:23:26 +0000 Subject: [PATCH] tests: robustify execve and execveat tests * tests/execve.c (main): Use one page gap between two mapped regions for an address that is more likely to be not yet mapped. * tests/execveat.c (main): Likewise. --- tests/execve.c | 3 +-- tests/execveat.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/execve.c b/tests/execve.c index 3d2bbe1d..82e32c60 100644 --- a/tests/execve.c +++ b/tests/execve.c @@ -105,6 +105,7 @@ main(void) ); char **const empty = tail_alloc(sizeof(*empty)); + char **const efault = empty + 1; *empty = NULL; execve(FILENAME, empty, empty); @@ -159,8 +160,6 @@ main(void) #endif printf("]) = -1 ENOENT (%m)\n"); - const void * const efault = tail_alloc(0); - execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault); printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n", Q_FILENAME, efault); diff --git a/tests/execveat.c b/tests/execveat.c index 8ac2cd18..d4ead406 100644 --- a/tests/execveat.c +++ b/tests/execveat.c @@ -107,7 +107,8 @@ main(void) #endif errno == ENOSYS ? "ENOSYS" : "ENOENT"); - const char **const empty = tail_alloc(sizeof(*empty)); + char **const empty = tail_alloc(sizeof(*empty)); + char **const efault = empty + 1; *empty = NULL; syscall(__NR_execveat, -100, FILENAME, empty, empty, 0x1100); @@ -165,8 +166,6 @@ main(void) printf("], AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n", errno == ENOSYS ? "ENOSYS" : "ENOENT"); - const void * const efault = tail_alloc(0); - syscall(__NR_execveat, -100, FILENAME, NULL, efault, 0x1100); printf("execveat(AT_FDCWD, \"%s\", NULL, %p" ", AT_SYMLINK_NOFOLLOW|AT_EMPTY_PATH) = -1 %s (%m)\n", -- 2.40.0