summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-26 17:57:58 +0200
committerBruno Haible <bruno@clisp.org>2020-05-27 19:30:43 +0200
commit3c0df2a7ffc173b200ea33eb689d33dc15d0175d (patch)
treecbb43bca1d669eb5e1bf6d0678d3e83055fbebfb
parent0f36ac3a248df78ee29a5ba69a835c6fce55e830 (diff)
downloadgnulib-3c0df2a7ffc173b200ea33eb689d33dc15d0175d.tar.gz
gnulib-3c0df2a7ffc173b200ea33eb689d33dc15d0175d.tar.bz2
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.
-rw-r--r--ChangeLog6
-rw-r--r--lib/readutmp.c2
-rw-r--r--modules/readutmp1
3 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a9f542fede..8f89928f4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2020-05-27 Bruno Haible <bruno@clisp.org>
+ 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-27 Bruno Haible <bruno@clisp.org>
+
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 308390de1c..793d480d29 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 51f629002b..e88897c999 100644
--- a/modules/readutmp
+++ b/modules/readutmp
@@ -11,6 +11,7 @@ extensions
xalloc
stdbool
stdint
+fopen-gnu
configure.ac:
gl_READUTMP

Return to:

Send suggestions and report system problems to the System administrator.