mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Make some small fixes to recent changes
This commit is contained in:
parent
c2590cf7a0
commit
179e048bba
5 changed files with 33 additions and 11 deletions
|
@ -18,11 +18,14 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/mfd.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/testlib/subprocess.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
// clang-format off
|
||||
|
||||
int fds[2];
|
||||
char buf[8];
|
||||
|
@ -64,3 +67,22 @@ TEST(fexecve, elfIsUnreadable_mayBeExecuted) {
|
|||
ASSERT_SYS(0, 0, close(3));
|
||||
ASSERT_STREQ("hi\n", buf);
|
||||
}
|
||||
|
||||
TEST(fexecve, memfd_create) {
|
||||
if (!IsLinux()) return;
|
||||
SPAWN(vfork);
|
||||
#define TINY_ELF_PROGRAM "\
|
||||
\177\105\114\106\002\001\001\000\000\000\000\000\000\000\000\000\
|
||||
\002\000\076\000\001\000\000\000\170\000\100\000\000\000\000\000\
|
||||
\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
|
||||
\000\000\000\000\100\000\070\000\001\000\000\000\000\000\000\000\
|
||||
\001\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000\
|
||||
\000\000\100\000\000\000\000\000\000\000\100\000\000\000\000\000\
|
||||
\200\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\
|
||||
\000\020\000\000\000\000\000\000\152\052\137\152\074\130\017\005"
|
||||
int fd = memfd_create("foo", MFD_CLOEXEC);
|
||||
if (fd == -1 && errno == ENOSYS) _Exit(42);
|
||||
write(fd, TINY_ELF_PROGRAM, sizeof(TINY_ELF_PROGRAM) - 1);
|
||||
fexecve(fd, (char *const[]){0}, (char *const[]){0});
|
||||
EXITS(42);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,9 @@ o/$(MODE)/test/libc/calls/lock_ofd_test.com.runs: \
|
|||
o/$(MODE)/test/libc/calls/openbsd_test.com.runs: \
|
||||
private .PLEDGE = stdio rpath wpath cpath fattr proc unveil
|
||||
|
||||
o/$(MODE)/test/libc/calls/fexecve_test.com.runs: \
|
||||
private .UNSANDBOXED = 1 # for memfd_create()
|
||||
|
||||
o/$(MODE)/test/libc/calls/read_test.com.runs: \
|
||||
private .UNVEIL += /dev/zero
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue