diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-10-08 13:04:15 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-10-08 16:11:13 +0200 |
commit | 32036901707cc86e16b8d9f65bb4686a9bbb0a5c (patch) | |
tree | 6561e14fbcc02fe5d7d943d721662e2d1eeaaae1 /posix/wordexp-test.c | |
parent | nptl: Move pthread_attr_setschedparam implementation into libc (diff) | |
download | glibc-32036901707cc86e16b8d9f65bb4686a9bbb0a5c.tar.gz glibc-32036901707cc86e16b8d9f65bb4686a9bbb0a5c.tar.bz2 glibc-32036901707cc86e16b8d9f65bb4686a9bbb0a5c.zip |
wordexp: Split out command execution tests from posix/wordexp-test
Once wordexp switches to posix_spawn, testing for command execution
based on fork handlers will not work anymore. Therefore, move these
subtests into a new test, posix/tst-wordexp-nocmd, which uses a
different form of command execution detection, based on PID
namespaces.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'posix/wordexp-test.c')
-rw-r--r-- | posix/wordexp-test.c | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c index 957184cf47..a4d8bcf1da 100644 --- a/posix/wordexp-test.c +++ b/posix/wordexp-test.c @@ -31,23 +31,6 @@ #define IFS " \n\t" -extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *); - -static int __app_register_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void)) -{ - return __register_atfork (prepare, parent, child, __dso_handle); -} - -/* Number of forks seen. */ -static int registered_forks; - -/* For each fork increment the fork count. */ -static void -register_fork (void) -{ - registered_forks++; -} - struct test_case_struct { int retval; @@ -217,7 +200,6 @@ struct test_case_struct { WRDE_BADCHAR, NULL, "close-paren)", 0, 0, { NULL, }, IFS }, { WRDE_BADCHAR, NULL, "{open-brace", 0, 0, { NULL, }, IFS }, { WRDE_BADCHAR, NULL, "close-brace}", 0, 0, { NULL, }, IFS }, - { WRDE_CMDSUB, NULL, "$(ls)", WRDE_NOCMD, 0, { NULL, }, IFS }, { WRDE_BADVAL, NULL, "$var", WRDE_UNDEF, 0, { NULL, }, IFS }, { WRDE_BADVAL, NULL, "$9", WRDE_UNDEF, 0, { NULL, }, IFS }, { WRDE_SYNTAX, NULL, "$[50+20))", 0, 0, { NULL, }, IFS }, @@ -227,17 +209,10 @@ struct test_case_struct { WRDE_SYNTAX, NULL, "$((2+))", 0, 0, { NULL, }, IFS }, { WRDE_SYNTAX, NULL, "`", 0, 0, { NULL, }, IFS }, { WRDE_SYNTAX, NULL, "$((010+4+))", 0, 0, { NULL }, IFS }, - /* Test for CVE-2014-7817. We test 3 combinations of command - substitution inside an arithmetic expression to make sure that - no commands are executed and error is returned. */ - { WRDE_CMDSUB, NULL, "$((`echo 1`))", WRDE_NOCMD, 0, { NULL, }, IFS }, - { WRDE_CMDSUB, NULL, "$((1+`echo 1`))", WRDE_NOCMD, 0, { NULL, }, IFS }, - { WRDE_CMDSUB, NULL, "$((1+$((`echo 1`))))", WRDE_NOCMD, 0, { NULL, }, IFS }, { WRDE_SYNTAX, NULL, "`\\", 0, 0, { NULL, }, IFS }, /* BZ 18042 */ { WRDE_SYNTAX, NULL, "${", 0, 0, { NULL, }, IFS }, /* BZ 18043 */ { WRDE_SYNTAX, NULL, "L${a:", 0, 0, { NULL, }, IFS }, /* BZ 18043#c4 */ - { WRDE_SYNTAX, NULL, "$[1/0]", WRDE_NOCMD, 0, {NULL, }, IFS }, /* BZ 18100 */ { -1, NULL, NULL, 0, 0, { NULL, }, IFS }, }; @@ -290,15 +265,6 @@ main (int argc, char *argv[]) return -1; } - /* If we are not allowed to do command substitution, we install - fork handlers to verify that no forks happened. No forks should - happen at all if command substitution is disabled. */ - if (__app_register_atfork (register_fork, NULL, NULL) != 0) - { - printf ("Failed to register fork handler.\n"); - return -1; - } - for (test = 0; test_case[test].retval != -1; test++) if (testit (&test_case[test])) ++fail; @@ -363,45 +329,6 @@ main (int argc, char *argv[]) ++fail; } - /* Integer overflow in division. */ - { - static const char *const numbers[] = { - "0", - "1", - "65536", - "2147483648", - "4294967296" - "9223372036854775808", - "18446744073709551616", - "170141183460469231731687303715884105728", - "340282366920938463463374607431768211456", - NULL - }; - - for (const char *const *num = numbers; *num; ++num) - { - wordexp_t p; - char pattern[256]; - snprintf (pattern, sizeof (pattern), "$[(-%s)/(-1)]", *num); - int ret = wordexp (pattern, &p, WRDE_NOCMD); - if (ret == 0) - { - if (p.we_wordc != 1 || strcmp (p.we_wordv[0], *num) != 0) - { - printf ("Integer overflow for \"%s\" failed", pattern); - ++fail; - } - wordfree (&p); - } - else if (ret != WRDE_SYNTAX) - { - printf ("Integer overflow for \"%s\" failed with %d", - pattern, ret); - ++fail; - } - } - } - puts ("tests completed, now cleaning up"); /* Clean up */ @@ -472,9 +399,6 @@ testit (struct test_case_struct *tc) fflush (NULL); const char *words = at_page_end (tc->words); - if (tc->flags & WRDE_NOCMD) - registered_forks = 0; - if (tc->flags & WRDE_APPEND) { /* initial wordexp() call, to be appended to */ @@ -486,13 +410,6 @@ testit (struct test_case_struct *tc) } retval = wordexp (words, &we, tc->flags); - if ((tc->flags & WRDE_NOCMD) - && (registered_forks > 0)) - { - printf ("FAILED fork called for WRDE_NOCMD\n"); - return 1; - } - if (tc->flags & WRDE_DOOFFS) start_offs = sav_we.we_offs; |