Add crash proofing to ipv4.games server

This commit is contained in:
Justine Tunney 2024-08-26 12:36:45 -07:00
parent e7b586e7f8
commit ebe1cbb1e3
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 256 additions and 33 deletions

View file

@ -109,12 +109,15 @@ TEST(pledge, execpromises_notok) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
putenv("COMDBG=REDACTED");
__pledge_mode = PLEDGE_PENALTY_RETURN_EPERM;
ASSERT_SYS(0, 0, pledge("stdio rpath exec", "stdio"));
execl("sock.elf", "sock.elf", 0);
_Exit(127);
}
EXPECT_NE(-1, wait(&ws));
EXPECT_FALSE(WIFSIGNALED(ws));
EXPECT_EQ(0, WTERMSIG(ws));
EXPECT_TRUE(WIFEXITED(ws));
EXPECT_EQ(129, WEXITSTATUS(ws));
}
@ -532,6 +535,7 @@ TEST(pledge, execpromises_ok) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
putenv("COMDBG=REDACTED");
ASSERT_SYS(0, 0, pledge("stdio exec", "stdio"));
execl("life.elf", "life.elf", 0);
_Exit(127);
@ -547,6 +551,7 @@ TEST(pledge, execpromises_notok1) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
putenv("COMDBG=REDACTED");
ASSERT_SYS(0, 0, pledge("stdio exec", "stdio"));
execl("sock.elf", "sock.elf", 0);
_Exit(127);
@ -562,6 +567,7 @@ TEST(pledge, execpromises_reducesAtExecOnLinux) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
putenv("COMDBG=REDACTED");
ASSERT_SYS(0, 0, pledge("stdio inet tty exec", "stdio tty"));
execl("sock.elf", "sock.elf", 0);
_Exit(127);
@ -619,6 +625,7 @@ TEST(pledge_openbsd, execpromises_notok) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
putenv("COMDBG=REDACTED");
ASSERT_SYS(0, 0, pledge("stdio exec", "stdio"));
execl("sock.elf", "sock.elf", 0);
_Exit(127);