posix: accept inode 0 is a valid inode number (BZ #19971)
[glibc.git] / posix / wordexp-test.c
blob17ae812346979a576845f625887a59cf85653430
1 /* Copyright (C) 1997-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <sys/stat.h>
19 #include <sys/types.h>
20 #include <sys/mman.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23 #include <pwd.h>
24 #include <stdio.h>
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <wordexp.h>
29 #include <libc-pointer-arith.h>
31 #define IFS " \n\t"
33 extern void *__dso_handle __attribute__ ((__weak__, __visibility__ ("hidden")));
34 extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *);
36 static int __app_register_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void))
38 return __register_atfork (prepare, parent, child,
39 &__dso_handle == NULL ? NULL : __dso_handle);
42 /* Number of forks seen. */
43 static int registered_forks;
45 /* For each fork increment the fork count. */
46 static void
47 register_fork (void)
49 registered_forks++;
52 struct test_case_struct
54 int retval;
55 const char *env;
56 const char *words;
57 int flags;
58 size_t wordc;
59 const char *wordv[10];
60 const char *ifs;
61 } test_case[] =
63 /* Simple word- and field-splitting */
64 { 0, NULL, "one", 0, 1, { "one", }, IFS },
65 { 0, NULL, "one two", 0, 2, { "one", "two", }, IFS },
66 { 0, NULL, "one two three", 0, 3, { "one", "two", "three", }, IFS },
67 { 0, NULL, " \tfoo\t\tbar ", 0, 2, { "foo", "bar", }, IFS },
68 { 0, NULL, "red , white blue", 0, 4, { "red", ",", "white", "blue", }, " ," },
69 { 0, NULL, "one two three", 0, 3, { "one", "two", "three", }, "" },
70 { 0, NULL, "one \"two three\"", 0, 2, { "one", "two three", }, IFS },
71 { 0, NULL, "one \"two three\"", 0, 2, { "one", "two three", }, "" },
72 { 0, "two three", "one \"$var\"", 0, 2, { "one", "two three", }, IFS },
73 { 0, "two three", "one $var", 0, 3, { "one", "two", "three", }, IFS },
74 { 0, "two three", "one \"$var\"", 0, 2, { "one", "two three", }, "" },
75 { 0, "two three", "one $var", 0, 2, { "one", "two three", }, "" },
77 /* The non-whitespace IFS char at the end delimits the second field
78 * but does NOT start a new field. */
79 { 0, ":abc:", "$var", 0, 2, { "", "abc", }, ":" },
81 { 0, NULL, "$(echo :abc:)", 0, 2, { "", "abc", }, ":" },
82 { 0, NULL, "$(echo :abc:\\ )", 0, 2, { "", "abc", }, ": " },
83 { 0, NULL, "$(echo :abc\\ )", 0, 2, { "", "abc", }, ": " },
84 { 0, ":abc:", "$(echo $var)", 0, 2, { "", "abc", }, ":" },
85 { 0, NULL, ":abc:", 0, 1, { ":abc:", }, ":" },
86 { 0, NULL, "$(echo :abc:)def", 0, 3, { "", "abc", "def", },
87 ":" },
88 { 0, NULL, "$(echo abc:de)f", 0, 2, { "abc", "def", }, ":" },
89 { 0, NULL, "$(echo abc:de)f:ghi", 0, 2, { "abc", "def:ghi", },
90 ":" },
91 { 0, NULL, "abc:d$(echo ef:ghi)", 0, 2, { "abc:def", "ghi", },
92 ":" },
93 { 0, "abc:", "$var$(echo def:ghi)", 0, 3, { "abc", "def",
94 "ghi", }, ":" },
95 { 0, "abc:d", "$var$(echo ef:ghi)", 0, 3, { "abc", "def",
96 "ghi", }, ":" },
97 { 0, "def:ghi", "$(echo abc:)$var", 0, 3, { "abc", "def",
98 "ghi", }, ":" },
99 { 0, "ef:ghi", "$(echo abc:d)$var", 0, 3, { "abc", "def",
100 "ghi", }, ":" },
102 /* Simple parameter expansion */
103 { 0, "foo", "${var}", 0, 1, { "foo", }, IFS },
104 { 0, "foo", "$var", 0, 1, { "foo", }, IFS },
105 { 0, "foo", "\\\"$var\\\"", 0, 1, { "\"foo\"", }, IFS },
106 { 0, "foo", "%$var%", 0, 1, { "%foo%", }, IFS },
107 { 0, "foo", "-$var-", 0, 1, { "-foo-", }, IFS },
109 /* Simple quote removal */
110 { 0, NULL, "\"quoted\"", 0, 1, { "quoted", }, IFS },
111 { 0, "foo", "\"$var\"\"$var\"", 0, 1, { "foofoo", }, IFS },
112 { 0, NULL, "'singly-quoted'", 0, 1, { "singly-quoted", }, IFS },
113 { 0, NULL, "contin\\\nuation", 0, 1, { "continuation", }, IFS },
114 { 0, NULL, "explicit ''", 0, 2, { "explicit", "", }, IFS },
115 { 0, NULL, "explicit \"\"", 0, 2, { "explicit", "", }, IFS },
116 { 0, NULL, "explicit ``", 0, 1, { "explicit", }, IFS },
118 /* Simple command substitution */
119 { 0, NULL, "$(echo hello)", 0, 1, { "hello", }, IFS },
120 { 0, NULL, "$( (echo hello) )", 0, 1, { "hello", }, IFS },
121 { 0, NULL, "$((echo hello);(echo there))", 0, 2, { "hello", "there", }, IFS },
122 { 0, NULL, "`echo one two`", 0, 2, { "one", "two", }, IFS },
123 { 0, NULL, "$(echo ')')", 0, 1, { ")" }, IFS },
124 { 0, NULL, "$(echo hello; echo)", 0, 1, { "hello", }, IFS },
125 { 0, NULL, "a$(echo b)c", 0, 1, { "abc", }, IFS },
127 /* Simple arithmetic expansion */
128 { 0, NULL, "$((1 + 1))", 0, 1, { "2", }, IFS },
129 { 0, NULL, "$((2-3))", 0, 1, { "-1", }, IFS },
130 { 0, NULL, "$((-1))", 0, 1, { "-1", }, IFS },
131 { 0, NULL, "$[50+20]", 0, 1, { "70", }, IFS },
132 { 0, NULL, "$(((2+3)*(4+5)))", 0, 1, { "45", }, IFS },
133 { 0, NULL, "$((010))", 0, 1, { "8" }, IFS },
134 { 0, NULL, "$((0x10))", 0, 1, { "16" }, IFS },
135 { 0, NULL, "$((010+0x10))", 0, 1, { "24" }, IFS },
136 { 0, NULL, "$((-010+0x10))", 0, 1, { "8" }, IFS },
137 { 0, NULL, "$((-0x10+010))", 0, 1, { "-8" }, IFS },
139 /* Advanced parameter expansion */
140 { 0, NULL, "${var:-bar}", 0, 1, { "bar", }, IFS },
141 { 0, NULL, "${var-bar}", 0, 1, { "bar", }, IFS },
142 { 0, "", "${var:-bar}", 0, 1, { "bar", }, IFS },
143 { 0, "foo", "${var:-bar}", 0, 1, { "foo", }, IFS },
144 { 0, "", "${var-bar}", 0, 0, { NULL, }, IFS },
145 { 0, NULL, "${var:=bar}", 0, 1, { "bar", }, IFS },
146 { 0, NULL, "${var=bar}", 0, 1, { "bar", }, IFS },
147 { 0, "", "${var:=bar}", 0, 1, { "bar", }, IFS },
148 { 0, "foo", "${var:=bar}", 0, 1, { "foo", }, IFS },
149 { 0, "", "${var=bar}", 0, 0, { NULL, }, IFS },
150 { 0, "foo", "${var:?bar}", 0, 1, { "foo", }, IFS },
151 { 0, NULL, "${var:+bar}", 0, 0, { NULL, }, IFS },
152 { 0, NULL, "${var+bar}", 0, 0, { NULL, }, IFS },
153 { 0, "", "${var:+bar}", 0, 0, { NULL, }, IFS },
154 { 0, "foo", "${var:+bar}", 0, 1, { "bar", }, IFS },
155 { 0, "", "${var+bar}", 0, 1, { "bar", }, IFS },
156 { 0, "12345", "${#var}", 0, 1, { "5", }, IFS },
157 { 0, NULL, "${var:-'}'}", 0, 1, { "}", }, IFS },
158 { 0, NULL, "${var-}", 0, 0, { NULL }, IFS },
160 { 0, "pizza", "${var#${var}}", 0, 0, { NULL }, IFS },
161 { 0, "pepperoni", "${var%$(echo oni)}", 0, 1, { "pepper" }, IFS },
162 { 0, "6pack", "${var#$((6))}", 0, 1, { "pack" }, IFS },
163 { 0, "b*witched", "${var##b*}", 0, 0, { NULL }, IFS },
164 { 0, "b*witched", "${var##\"b*\"}", 0, 1, { "witched" }, IFS },
165 { 0, "banana", "${var%na*}", 0, 1, { "bana", }, IFS },
166 { 0, "banana", "${var%%na*}", 0, 1, { "ba", }, IFS },
167 { 0, "borabora-island", "${var#*bora}", 0, 1, { "bora-island", }, IFS },
168 { 0, "borabora-island", "${var##*bora}", 0, 1, { "-island", }, IFS },
169 { 0, "coconut", "${var##\\*co}", 0, 1, { "coconut", }, IFS },
170 { 0, "100%", "${var%0%}", 0, 1, { "10" }, IFS },
172 /* Pathname expansion */
173 { 0, NULL, "???", 0, 2, { "one", "two", }, IFS },
174 { 0, NULL, "[ot]??", 0, 2, { "one", "two", }, IFS },
175 { 0, NULL, "t*", 0, 2, { "three", "two", }, IFS },
176 { 0, NULL, "\"t\"*", 0, 2, { "three", "two", }, IFS },
178 /* Nested constructs */
179 { 0, "one two", "$var", 0, 2, { "one", "two", }, IFS },
180 { 0, "one two three", "$var", 0, 3, { "one", "two", "three", }, IFS },
181 { 0, " \tfoo\t\tbar ", "$var", 0, 2, { "foo", "bar", }, IFS },
182 { 0, " red , white blue", "$var", 0, 3, { "red", "white", "blue", }, ", \n\t" },
183 { 0, " red , white blue", "\"$var\"", 0, 1, { " red , white blue", }, ", \n\t" },
184 { 0, NULL, "\"$(echo hello there)\"", 0, 1, { "hello there", }, IFS },
185 { 0, NULL, "\"$(echo \"hello there\")\"", 0, 1, { "hello there", }, IFS },
186 { 0, NULL, "${var=one two} \"$var\"", 0, 3, { "one", "two", "one two", }, IFS },
187 { 0, "1", "$(( $(echo 3)+$var ))", 0, 1, { "4", }, IFS },
188 { 0, NULL, "\"$(echo \"*\")\"", 0, 1, { "*", }, IFS },
189 { 0, NULL, "\"a\n\n$(echo)b\"", 0, 1, { "a\n\nb", }, IFS },
190 { 0, "foo", "*$var*", 0, 1, { "*foo*", }, IFS },
191 { 0, "o thr", "*$var*", 0, 2, { "two", "three" }, IFS },
193 /* Different IFS values */
194 { 0, "a b\tc\nd ", "$var", 0, 4, { "a", "b", "c", "d" }, NULL /* unset */ },
195 { 0, "a b\tc d ", "$var", 0, 1, { "a b\tc d " }, "" /* `null' */ },
196 { 0, "a,b c\n, d", "$var", 0, 3, { "a", "b c", " d" }, "\t\n," },
198 /* Other things that should succeed */
199 { 0, NULL, "\\*\"|&;<>\"\\(\\)\\{\\}", 0, 1, { "*|&;<>(){}", }, IFS },
200 { 0, "???", "$var", 0, 1, { "???", }, IFS },
201 { 0, NULL, "$var", 0, 0, { NULL, }, IFS },
202 { 0, NULL, "\"\\n\"", 0, 1, { "\\n", }, IFS },
203 { 0, NULL, "", 0, 0, { NULL, }, IFS },
205 /* Flags not already covered (testit() has special handling for these) */
206 { 0, NULL, "one two", WRDE_DOOFFS, 2, { "one", "two", }, IFS },
207 { 0, NULL, "appended", WRDE_APPEND, 3, { "pre1", "pre2", "appended", }, IFS },
208 { 0, NULL, "appended", WRDE_DOOFFS|WRDE_APPEND, 3, { "pre1", "pre2", "appended", }, IFS },
210 /* Things that should fail */
211 { WRDE_BADCHAR, NULL, "new\nline", 0, 0, { NULL, }, "" /* \n not IFS */ },
212 { WRDE_BADCHAR, NULL, "pipe|symbol", 0, 0, { NULL, }, IFS },
213 { WRDE_BADCHAR, NULL, "&ampersand", 0, 0, { NULL, }, IFS },
214 { WRDE_BADCHAR, NULL, "semi;colon", 0, 0, { NULL, }, IFS },
215 { WRDE_BADCHAR, NULL, "<greater", 0, 0, { NULL, }, IFS },
216 { WRDE_BADCHAR, NULL, "less>", 0, 0, { NULL, }, IFS },
217 { WRDE_BADCHAR, NULL, "(open-paren", 0, 0, { NULL, }, IFS },
218 { WRDE_BADCHAR, NULL, "close-paren)", 0, 0, { NULL, }, IFS },
219 { WRDE_BADCHAR, NULL, "{open-brace", 0, 0, { NULL, }, IFS },
220 { WRDE_BADCHAR, NULL, "close-brace}", 0, 0, { NULL, }, IFS },
221 { WRDE_CMDSUB, NULL, "$(ls)", WRDE_NOCMD, 0, { NULL, }, IFS },
222 { WRDE_BADVAL, NULL, "$var", WRDE_UNDEF, 0, { NULL, }, IFS },
223 { WRDE_BADVAL, NULL, "$9", WRDE_UNDEF, 0, { NULL, }, IFS },
224 { WRDE_SYNTAX, NULL, "$[50+20))", 0, 0, { NULL, }, IFS },
225 { WRDE_SYNTAX, NULL, "${%%noparam}", 0, 0, { NULL, }, IFS },
226 { WRDE_SYNTAX, NULL, "${missing-brace", 0, 0, { NULL, }, IFS },
227 { WRDE_SYNTAX, NULL, "$(for i in)", 0, 0, { NULL, }, IFS },
228 { WRDE_SYNTAX, NULL, "$((2+))", 0, 0, { NULL, }, IFS },
229 { WRDE_SYNTAX, NULL, "`", 0, 0, { NULL, }, IFS },
230 { WRDE_SYNTAX, NULL, "$((010+4+))", 0, 0, { NULL }, IFS },
231 /* Test for CVE-2014-7817. We test 3 combinations of command
232 substitution inside an arithmetic expression to make sure that
233 no commands are executed and error is returned. */
234 { WRDE_CMDSUB, NULL, "$((`echo 1`))", WRDE_NOCMD, 0, { NULL, }, IFS },
235 { WRDE_CMDSUB, NULL, "$((1+`echo 1`))", WRDE_NOCMD, 0, { NULL, }, IFS },
236 { WRDE_CMDSUB, NULL, "$((1+$((`echo 1`))))", WRDE_NOCMD, 0, { NULL, }, IFS },
238 { WRDE_SYNTAX, NULL, "`\\", 0, 0, { NULL, }, IFS }, /* BZ 18042 */
239 { WRDE_SYNTAX, NULL, "${", 0, 0, { NULL, }, IFS }, /* BZ 18043 */
240 { WRDE_SYNTAX, NULL, "L${a:", 0, 0, { NULL, }, IFS }, /* BZ 18043#c4 */
241 { WRDE_SYNTAX, NULL, "$[1/0]", WRDE_NOCMD, 0, {NULL, }, IFS }, /* BZ 18100 */
243 { -1, NULL, NULL, 0, 0, { NULL, }, IFS },
246 static int testit (struct test_case_struct *tc);
247 static int tests;
249 static void
250 command_line_test (const char *words)
252 wordexp_t we;
253 int i;
254 int retval = wordexp (words, &we, 0);
255 printf ("wordexp returned %d\n", retval);
256 for (i = 0; i < we.we_wordc; i++)
257 printf ("we_wordv[%d] = \"%s\"\n", i, we.we_wordv[i]);
261 main (int argc, char *argv[])
263 const char *globfile[] = { "one", "two", "three", NULL };
264 char tmpdir[32];
265 struct passwd *pw;
266 const char *cwd;
267 int test;
268 int fail = 0;
269 int i;
270 struct test_case_struct ts;
272 if (argc > 1)
274 command_line_test (argv[1]);
275 return 0;
278 cwd = getcwd (NULL, 0);
280 /* Set up arena for pathname expansion */
281 tmpnam (tmpdir);
282 if (mkdir (tmpdir, S_IRWXU) || chdir (tmpdir))
283 return -1;
284 else
286 int fd;
288 for (i = 0; globfile[i]; ++i)
289 if ((fd = creat (globfile[i], S_IRUSR | S_IWUSR)) == -1
290 || close (fd))
291 return -1;
294 /* If we are not allowed to do command substitution, we install
295 fork handlers to verify that no forks happened. No forks should
296 happen at all if command substitution is disabled. */
297 if (__app_register_atfork (register_fork, NULL, NULL) != 0)
299 printf ("Failed to register fork handler.\n");
300 return -1;
303 for (test = 0; test_case[test].retval != -1; test++)
304 if (testit (&test_case[test]))
305 ++fail;
307 /* Tilde-expansion tests. */
308 pw = getpwnam ("root");
309 if (pw != NULL)
311 ts.retval = 0;
312 ts.env = NULL;
313 ts.words = "~root ";
314 ts.flags = 0;
315 ts.wordc = 1;
316 ts.wordv[0] = pw->pw_dir;
317 ts.ifs = IFS;
319 if (testit (&ts))
320 ++fail;
322 ts.retval = 0;
323 ts.env = pw->pw_dir;
324 ts.words = "${var#~root}x";
325 ts.flags = 0;
326 ts.wordc = 1;
327 ts.wordv[0] = "x";
328 ts.ifs = IFS;
330 if (testit (&ts))
331 ++fail;
334 /* "~" expands to value of $HOME when HOME is set */
336 setenv ("HOME", "/dummy/home", 1);
337 ts.retval = 0;
338 ts.env = NULL;
339 ts.words = "~ ~/foo";
340 ts.flags = 0;
341 ts.wordc = 2;
342 ts.wordv[0] = "/dummy/home";
343 ts.wordv[1] = "/dummy/home/foo";
344 ts.ifs = IFS;
346 if (testit (&ts))
347 ++fail;
349 /* "~" expands to home dir from passwd file if HOME is not set */
351 pw = getpwuid (getuid ());
352 if (pw != NULL)
354 unsetenv ("HOME");
355 ts.retval = 0;
356 ts.env = NULL;
357 ts.words = "~";
358 ts.flags = 0;
359 ts.wordc = 1;
360 ts.wordv[0] = pw->pw_dir;
361 ts.ifs = IFS;
363 if (testit (&ts))
364 ++fail;
367 /* Integer overflow in division. */
369 static const char *const numbers[] = {
370 "0",
371 "1",
372 "65536",
373 "2147483648",
374 "4294967296"
375 "9223372036854775808",
376 "18446744073709551616",
377 "170141183460469231731687303715884105728",
378 "340282366920938463463374607431768211456",
379 NULL
382 for (const char *const *num = numbers; *num; ++num)
384 wordexp_t p;
385 char pattern[256];
386 snprintf (pattern, sizeof (pattern), "$[(-%s)/(-1)]", *num);
387 int ret = wordexp (pattern, &p, WRDE_NOCMD);
388 if (ret == 0)
390 if (p.we_wordc != 1 || strcmp (p.we_wordv[0], *num) != 0)
392 printf ("Integer overflow for \"%s\" failed", pattern);
393 ++fail;
395 wordfree (&p);
397 else if (ret != WRDE_SYNTAX)
399 printf ("Integer overflow for \"%s\" failed with %d",
400 pattern, ret);
401 ++fail;
406 puts ("tests completed, now cleaning up");
408 /* Clean up */
409 for (i = 0; globfile[i]; ++i)
410 remove (globfile[i]);
412 if (cwd == NULL)
413 cwd = "..";
415 chdir (cwd);
416 rmdir (tmpdir);
418 printf ("tests failed: %d\n", fail);
420 return fail != 0;
423 static const char *
424 at_page_end (const char *words)
426 const int pagesize = getpagesize ();
427 char *start = mmap (0, 2 * pagesize, PROT_READ|PROT_WRITE,
428 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
430 if (start == MAP_FAILED)
431 return start;
433 if (mprotect (start + pagesize, pagesize, PROT_NONE))
435 munmap (start, 2 * pagesize);
436 return MAP_FAILED;
439 /* Includes terminating NUL. */
440 const size_t words_size = strlen (words) + 1;
441 char *words_start = start + pagesize - words_size;
442 memcpy (words_start, words, words_size);
444 return words_start;
447 static int
448 testit (struct test_case_struct *tc)
450 int retval;
451 wordexp_t we, sav_we;
452 char *dummy;
453 int bzzzt = 0;
454 int start_offs = 0;
455 int i;
457 if (tc->env)
458 setenv ("var", tc->env, 1);
459 else
460 unsetenv ("var");
462 if (tc->ifs)
463 setenv ("IFS", tc->ifs, 1);
464 else
465 unsetenv ("IFS");
467 sav_we.we_wordc = 99;
468 sav_we.we_wordv = &dummy;
469 sav_we.we_offs = 3;
470 we = sav_we;
472 printf ("Test %d (%s): ", ++tests, tc->words);
473 fflush (NULL);
474 const char *words = at_page_end (tc->words);
476 if (tc->flags & WRDE_NOCMD)
477 registered_forks = 0;
479 if (tc->flags & WRDE_APPEND)
481 /* initial wordexp() call, to be appended to */
482 if (wordexp ("pre1 pre2", &we, tc->flags & ~WRDE_APPEND) != 0)
484 printf ("FAILED setup\n");
485 return 1;
488 retval = wordexp (words, &we, tc->flags);
490 if ((tc->flags & WRDE_NOCMD)
491 && (registered_forks > 0))
493 printf ("FAILED fork called for WRDE_NOCMD\n");
494 return 1;
497 if (tc->flags & WRDE_DOOFFS)
498 start_offs = sav_we.we_offs;
500 if (retval != tc->retval || (retval == 0 && we.we_wordc != tc->wordc))
501 bzzzt = 1;
502 else if (retval == 0)
504 for (i = 0; i < start_offs; ++i)
505 if (we.we_wordv[i] != NULL)
507 bzzzt = 1;
508 break;
511 for (i = 0; i < we.we_wordc; ++i)
512 if (we.we_wordv[i+start_offs] == NULL ||
513 strcmp (tc->wordv[i], we.we_wordv[i+start_offs]) != 0)
515 bzzzt = 1;
516 break;
520 if (bzzzt)
522 printf ("FAILED\n");
523 printf ("Test words: <%s>, need retval %d, wordc %Zd\n",
524 tc->words, tc->retval, tc->wordc);
525 if (start_offs != 0)
526 printf ("(preceded by %d NULLs)\n", start_offs);
527 printf ("Got retval %d, wordc %Zd: ", retval, we.we_wordc);
528 if (retval == 0 || retval == WRDE_NOSPACE)
530 for (i = 0; i < we.we_wordc + start_offs; ++i)
531 if (we.we_wordv[i] == NULL)
532 printf ("NULL ");
533 else
534 printf ("<%s> ", we.we_wordv[i]);
536 printf ("\n");
538 else if (retval != 0 && retval != WRDE_NOSPACE &&
539 (we.we_wordc != sav_we.we_wordc ||
540 we.we_wordv != sav_we.we_wordv ||
541 we.we_offs != sav_we.we_offs))
543 bzzzt = 1;
544 printf ("FAILED to restore wordexp_t members\n");
546 else
547 printf ("OK\n");
549 if (retval == 0 || retval == WRDE_NOSPACE)
550 wordfree (&we);
552 const int page_size = getpagesize ();
553 char *start = (char *) PTR_ALIGN_DOWN (words, page_size);
555 if (munmap (start, 2 * page_size) != 0)
556 return 1;
558 fflush (NULL);
559 return bzzzt;