summaryrefslogtreecommitdiff
path: root/lib/file.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2020-05-25 10:09:28 +0200
committerDaiki Ueno <ueno@gnu.org>2020-05-30 11:10:11 +0200
commit96f2687b8073cdcf667e9fd8d237f44a1434348b (patch)
tree8ab75e142b0b72a07bcfbc91cf34c0a171958ee2 /lib/file.c
parent5b4989dc8e292b4a7e66ee3a1d6be7ad3abf6654 (diff)
downloadgnutls-96f2687b8073cdcf667e9fd8d237f44a1434348b.tar.gz
lib: avoid file descriptor leak when application forks
This makes use of the "e" flag of fopen, provided by the Gnulib's fopen-gnu module. Reported by Remi Denis-Courmont in: https://gitlab.com/gnutls/gnutls/-/issues/985 and fix suggested by Tim Rühsen. Signed-off-by: Daiki Ueno <ueno@gnu.org>
Diffstat (limited to 'lib/file.c')
-rw-r--r--lib/file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/file.c b/lib/file.c
index 2bcdee8b7e..03aa265c38 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -29,7 +29,7 @@ int _gnutls_file_exists(const char *file)
{
FILE *fd;
- fd = fopen(file, "r");
+ fd = fopen(file, "re");
if (fd == NULL)
return -1;