Global: add missing O_CLOEXEC to open()

This commit is contained in:
apocelipes
2025-06-19 18:11:54 +08:00
committed by Carter Li
parent 68fd21d0e4
commit 3291a9945f
17 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s
return "load libelf failed";
// Open the ELF file
FF_AUTO_CLOSE_FD int fd = open(elfFile, O_RDONLY, 0);
FF_AUTO_CLOSE_FD int fd = open(elfFile, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0) return "open() failed";
Elf* elf = elfData.ffelf_begin(fd, ELF_C_READ, NULL);
+3 -3
View File
@@ -183,7 +183,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
}
FF_DEBUG("Parsed SMBIOS entry address: 0x%lx", (unsigned long)entryAddress);
FF_AUTO_CLOSE_FD int fd = open("/dev/mem", O_RDONLY);
FF_AUTO_CLOSE_FD int fd = open("/dev/mem", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
FF_DEBUG("Failed to open /dev/mem: %s", strerror(errno));
return NULL;
@@ -219,7 +219,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
#endif
);
FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY);
FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
FF_DEBUG("Failed to open /dev/smbios: %s", strerror(errno));
return NULL;
@@ -328,7 +328,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
#else
"/dev/mem" // kern.securelevel must be -1
#endif
, O_RDONLY);
, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
FF_DEBUG("Failed to open memory device: %s", strerror(errno));
return NULL;