Add the 'e' flag to all fopen(3) calls
This change adds the 'e' flag to all fopen(3) calls so they get
O_CLOEXEC.
Bug: None
Test: make tests
Change-Id: I27eb4e99be4823bca4ed81e95abaa683f4b877d0
diff --git a/elfparse.c b/elfparse.c
index 3ee8c9d..e76ebc4 100644
--- a/elfparse.c
+++ b/elfparse.c
@@ -70,7 +70,7 @@
FILE *elf_file = NULL;
uint8_t pHeader[HEADERSIZE] = "";
- elf_file = fopen(path, "r");
+ elf_file = fopen(path, "re");
if (elf_file) {
if (fread(pHeader, 1, HEADERSIZE, elf_file) == HEADERSIZE) {
if (is_elf_magic(pHeader)) {
diff --git a/libminijail.c b/libminijail.c
index 974346b..6804ebb 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -896,7 +896,7 @@
if (!seccomp_should_parse_filters(j))
return;
- FILE *file = fopen(path, "r");
+ FILE *file = fopen(path, "re");
if (!file) {
pdie("failed to open seccomp filter file '%s'", path);
}
diff --git a/parse_seccomp_policy.cc b/parse_seccomp_policy.cc
index 09b90be..76e8ab8 100644
--- a/parse_seccomp_policy.cc
+++ b/parse_seccomp_policy.cc
@@ -18,7 +18,7 @@
return 1;
}
- FILE *f = fopen(argv[1], "r");
+ FILE *f = fopen(argv[1], "re");
if (!f) {
pdie("fopen(%s) failed", argv[1]);
}
diff --git a/syscall_filter_unittest.cc b/syscall_filter_unittest.cc
index b3bd59a..b93b7c9 100644
--- a/syscall_filter_unittest.cc
+++ b/syscall_filter_unittest.cc
@@ -1580,7 +1580,7 @@
ASSERT_NE(policy_file, nullptr);
/* Ensure the included (invalid) policy file exists. */
- FILE *included_file = fopen("./test/invalid_syscall_name.policy", "r");
+ FILE *included_file = fopen("./test/invalid_syscall_name.policy", "re");
ASSERT_NE(included_file, nullptr);
fclose(included_file);
@@ -1600,7 +1600,7 @@
ASSERT_NE(policy_file, nullptr);
/* Ensure the policy file exists. */
- FILE *included_file = fopen("./test/nested.policy", "r");
+ FILE *included_file = fopen("./test/nested.policy", "re");
ASSERT_NE(included_file, nullptr);
fclose(included_file);