1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-01-20 10:52:16 +01:00

Add "e" flag to fopen() calls

This adds the `e` flag to fopen() calls, making sure the `O_CLOEXEC` flag is
used. This makes sure that the file descriptor is being closed and not leaked
into child processes. This was an issues previously due to a missing fclose()
(#136).
This commit is contained in:
Karol Babioch 2018-04-05 14:32:04 +02:00
parent 079b975469
commit d51124e884
3 changed files with 3 additions and 3 deletions

View File

@ -819,7 +819,7 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
{ {
if(S_ISREG(st.st_mode)) if(S_ISREG(st.st_mode))
{ {
file = fopen(filename, "a"); file = fopen(filename, "ae");
if(file) if(file)
{ {
cfg->debug_file = file; cfg->debug_file = file;

2
util.c
View File

@ -188,7 +188,7 @@ int generate_random(void *buf, int len)
FILE *u; FILE *u;
int res; int res;
u = fopen("/dev/urandom", "r"); u = fopen("/dev/urandom", "re");
if (!u) { if (!u) {
return -1; return -1;
} }

View File

@ -237,7 +237,7 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u
umask(077); umask(077);
f = fopen (fn, "w"); f = fopen (fn, "we");
if (! f) { if (! f) {
fprintf (stderr, "Failed opening '%s' for writing : %s\n", fn, strerror (errno)); fprintf (stderr, "Failed opening '%s' for writing : %s\n", fn, strerror (errno));
goto out; goto out;