-
Notifications
You must be signed in to change notification settings - Fork 846
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protect preopened inodes from being closed (#5275)
- Loading branch information
Showing
10 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessing preopen fd was a success | ||
Closing preopen fd was a success | ||
accessing closed preopen fd was an EBADF error: true | ||
accessing closed preopen fd was an EBADF error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Successfully closed file! | ||
Successfully closed stderr! | ||
Successfully closed stdin! | ||
Successfully closed stdout! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <dirent.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
|
||
int main() { | ||
const char *expected_entries[] = {".", "..", "main.c", "main.wasm", "output", "run.sh", NULL}; | ||
|
||
for (int fd = 0; fd <= 5; fd++) { | ||
close(fd); | ||
} | ||
|
||
DIR *dir = opendir("."); | ||
if (!dir) { | ||
printf("opendir"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
struct dirent *entry; | ||
int i = 0; | ||
while ((entry = readdir(dir)) != NULL) { | ||
if (expected_entries[i] == NULL) { | ||
fprintf(stdout, "Unexpected extra entry: %s\n", entry->d_name); | ||
closedir(dir); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
int cmp_result = strcmp(entry->d_name, expected_entries[i]); | ||
if (cmp_result != 0) { | ||
printf("1"); | ||
return 1; | ||
} | ||
|
||
i++; | ||
} | ||
|
||
if (expected_entries[i] != NULL) { | ||
printf("1"); | ||
return 1; | ||
} | ||
|
||
closedir(dir); | ||
|
||
printf("0"); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
rm output | ||
|
||
$WASMER -q run main.wasm --dir . > output | ||
|
||
printf "0" | diff -u output - 1>/dev/null |