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:
parent
079b975469
commit
d51124e884
@ -819,7 +819,7 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
||||
{
|
||||
if(S_ISREG(st.st_mode))
|
||||
{
|
||||
file = fopen(filename, "a");
|
||||
file = fopen(filename, "ae");
|
||||
if(file)
|
||||
{
|
||||
cfg->debug_file = file;
|
||||
|
2
util.c
2
util.c
@ -188,7 +188,7 @@ int generate_random(void *buf, int len)
|
||||
FILE *u;
|
||||
int res;
|
||||
|
||||
u = fopen("/dev/urandom", "r");
|
||||
u = fopen("/dev/urandom", "re");
|
||||
if (!u) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u
|
||||
|
||||
umask(077);
|
||||
|
||||
f = fopen (fn, "w");
|
||||
f = fopen (fn, "we");
|
||||
if (! f) {
|
||||
fprintf (stderr, "Failed opening '%s' for writing : %s\n", fn, strerror (errno));
|
||||
goto out;
|
||||
|
Loading…
x
Reference in New Issue
Block a user