>From 56bcba9b1013176d52f1b25a3085695a3bd8d9b8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 26 May 2020 17:57:58 +0200 Subject: [PATCH 5/8] readutmp: Make more robust in multithreaded applications. * lib/readutmp.c (read_utmp): Pass an 'e' flag to fopen. * modules/readutmp (Depends-on): Add fopen-gnu. --- ChangeLog | 6 ++++++ lib/readutmp.c | 2 +- modules/readutmp | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 93d8b5a..893d080 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2020-05-26 Bruno Haible + readutmp: Make more robust in multithreaded applications. + * lib/readutmp.c (read_utmp): Pass an 'e' flag to fopen. + * modules/readutmp (Depends-on): Add fopen-gnu. + +2020-05-26 Bruno Haible + getpass: Make more robust in multithreaded applications. * lib/getpass.c (getpass): Pass an 'e' flag to fopen. * modules/getpass (Depends-on): Add fopen-gnu. diff --git a/lib/readutmp.c b/lib/readutmp.c index 308390d..793d480 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -132,7 +132,7 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, size_t n_alloc = 0; STRUCT_UTMP *utmp = NULL; int saved_errno; - FILE *f = fopen (file, "r"); + FILE *f = fopen (file, "re"); if (! f) return -1; diff --git a/modules/readutmp b/modules/readutmp index 51f6290..e88897c 100644 --- a/modules/readutmp +++ b/modules/readutmp @@ -11,6 +11,7 @@ extensions xalloc stdbool stdint +fopen-gnu configure.ac: gl_READUTMP -- 2.7.4