summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-06-22 11:38:25 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-22 11:39:41 -0700
commit4573e7d863d59d59c6a4f72f396f72b0f6458cb2 (patch)
treeda6c5ad68024010b681eaebdb39a7822e5ede7dd /test
parent282a6aea1b375d447fdf502c6660e92eb5e19cd4 (diff)
Check for invalid trailing / when traversing path in gofer OpenAt.
Updates #2923. PiperOrigin-RevId: 317700049
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/BUILD1
-rw-r--r--test/syscalls/linux/open.cc6
2 files changed, 7 insertions, 0 deletions
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD
index 46a98a4cd..f94c383ae 100644
--- a/test/syscalls/BUILD
+++ b/test/syscalls/BUILD
@@ -181,6 +181,7 @@ syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:exec_binary_test",
+ vfs2 = "True",
)
syscall_test(
diff --git a/test/syscalls/linux/open.cc b/test/syscalls/linux/open.cc
index 670c0284b..bb7d108e8 100644
--- a/test/syscalls/linux/open.cc
+++ b/test/syscalls/linux/open.cc
@@ -439,6 +439,12 @@ TEST_F(OpenTest, CanTruncateWithStrangePermissions) {
EXPECT_THAT(close(fd), SyscallSucceeds());
}
+TEST_F(OpenTest, OpenNonDirectoryWithTrailingSlash) {
+ const TempPath file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile());
+ const std::string bad_path = file.path() + "/";
+ EXPECT_THAT(open(bad_path.c_str(), O_RDONLY), SyscallFailsWithErrno(ENOTDIR));
+}
+
} // namespace
} // namespace testing