summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2018-07-29 22:30:33 +0000
committerBob Beck <beck@cvs.openbsd.org>2018-07-29 22:30:33 +0000
commit79a6f7d981c0275e5dc22f0d553c122e7d61e115 (patch)
treed057f8655f2ea0b6674a3a8ceebb376fde02bc8d /regress/sys
parent8e7add189aad4f191ba1801e1705b3f0f5246aee (diff)
Add regress for ensuring .. is appropriately *not* used as a
descending match
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/unveil/syscalls.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c
index 8fc5999fb1d..91c11584cb1 100644
--- a/regress/sys/kern/unveil/syscalls.c
+++ b/regress/sys/kern/unveil/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.13 2018/07/27 01:41:39 beck Exp $ */
+/* $OpenBSD: syscalls.c,v 1.14 2018/07/29 22:30:32 beck Exp $ */
/*
* Copyright (c) 2017-2018 Bob Beck <beck@openbsd.org>
@@ -777,6 +777,25 @@ test_bypassunveil(int do_uv)
return 0;
}
+
+static int
+test_dotdotup(int do_uv)
+{
+ UV_SHOULD_SUCCEED((open("/tmp/hello", O_RDWR|O_CREAT) == -1), "open");
+ if (do_uv) {
+ printf("testing dotdotup\n");
+ do_unveil2();
+ }
+ if ((chdir(uv_dir1) == -1)) {
+ err(1, "chdir");
+ }
+ UV_SHOULD_SUCCEED((open("./derp", O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_SUCCEED((open("derp", O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_ENOENT((open("../hello", O_RDWR|O_CREAT) == -1), "open");
+ UV_SHOULD_ENOENT((open(".././hello", O_RDWR|O_CREAT) == -1), "open");
+ return 0;
+}
+
int
main (int argc, char *argv[])
{
@@ -820,5 +839,6 @@ main (int argc, char *argv[])
failures += runcompare(test_dot);
failures += runcompare(test_bypassunveil);
failures += runcompare_internal(test_fork, 0);
+ failures += runcompare(test_dotdotup);
exit(failures);
}