From 500a47bc2fbf1a1c54f9bea97334b03b02cea350 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 29 May 2024 20:31:46 -0700 Subject: [PATCH] Fix undefined behavior in unit test Fixes #1194 --- test/libc/calls/open_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/libc/calls/open_test.c b/test/libc/calls/open_test.c index 4f1013a7b..6125684ba 100644 --- a/test/libc/calls/open_test.c +++ b/test/libc/calls/open_test.c @@ -356,18 +356,18 @@ TEST(open, readOnlyCreatMode) { ASSERT_EQ(0100500, st.st_mode); if (getuid()) { ASSERT_SYS(EACCES, -1, open("x", O_RDWR)); - ASSERT_SYS(EACCES, -1, open("x", O_RDWR | O_CREAT)); + ASSERT_SYS(EACCES, -1, open("x", O_RDWR | O_CREAT, 0666)); } else { // root is invulnerable to eacces ASSERT_SYS(0, 3, open("x", O_RDWR)); ASSERT_SYS(0, 0, close(3)); - ASSERT_SYS(0, 3, open("x", O_RDWR | O_CREAT)); + ASSERT_SYS(0, 3, open("x", O_RDWR | O_CREAT, 0666)); ASSERT_SYS(0, 0, close(3)); SPAWN(fork); setuid(1000); setgid(1000); ASSERT_SYS(EACCES, -1, open("x", O_RDWR)); - ASSERT_SYS(EACCES, -1, open("x", O_RDWR | O_CREAT)); + ASSERT_SYS(EACCES, -1, open("x", O_RDWR | O_CREAT, 0666)); EXITS(0); } }