diff options
author | Nick Kralevich <nnk@google.com> | 2017-01-17 18:56:52 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-17 22:00:18 (GMT) |
commit | 64b12a065ae4fb84ae92299037c7eb8526549c85 (patch) | |
tree | 9b4373c4177a3879e930d1e512b1d13d0b48b321 /lib/utils.c | |
parent | 29139123df434b32f5e3ada56bece028a759bfb8 (diff) | |
download | libnl-64b12a065ae4fb84ae92299037c7eb8526549c85.zip libnl-64b12a065ae4fb84ae92299037c7eb8526549c85.tar.gz libnl-64b12a065ae4fb84ae92299037c7eb8526549c85.tar.bz2 |
fopen: add O_CLOEXEC
Add O_CLOEXEC to various fopen() calls. This avoids file descriptors
leaking across an exec() boundary in a multi-threaded program. Please
see "man 2 open" for additional information about O_CLOEXEC.
Signed-off-by: Nick Kralevich <nnk@google.com>
https://github.com/thom311/libnl/pull/128
Diffstat (limited to 'lib/utils.c')
-rw-r--r-- | lib/utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/utils.c b/lib/utils.c index fead196..64e87b6 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -75,7 +75,7 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *)) FILE *fd; char buf[128]; - fd = fopen(path, "r"); + fd = fopen(path, "re"); if (fd == NULL) return -nl_syserr2nlerr(errno); @@ -470,7 +470,7 @@ static void get_psched_settings(void) else strncpy(name, "/proc/net/psched", sizeof(name) - 1); - if ((fd = fopen(name, "r"))) { + if ((fd = fopen(name, "re"))) { unsigned int ns_per_usec, ns_per_tick, nom, denom; if (fscanf(fd, "%08x %08x %08x %08x", |