diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-07-16 16:21:28 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-07-21 07:33:08 +0200 |
commit | 23ed36735af09c258e542266aaed92cdd8571c6c (patch) | |
tree | 9e04621817d3613667d652b58b32f5854c416073 /nss/nss_compat/compat-initgroups.c | |
parent | 299210c1fa67e2dfb564475986fce11cd33db9ad (diff) | |
download | glibc-23ed36735af09c258e542266aaed92cdd8571c6c.tar.gz glibc-23ed36735af09c258e542266aaed92cdd8571c6c.tar.xz glibc-23ed36735af09c258e542266aaed92cdd8571c6c.zip |
nss_compat: Do not use mmap to read database files (bug 26258)
This avoids crashes in case the files are truncated for some reason. For typically file sizes, it is also going to be slightly faster. Using __nss_files_fopen instead mirrors what nss_files does. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'nss/nss_compat/compat-initgroups.c')
-rw-r--r-- | nss/nss_compat/compat-initgroups.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c index 3671bef48b..c0dcdf839d 100644 --- a/nss/nss_compat/compat-initgroups.c +++ b/nss/nss_compat/compat-initgroups.c @@ -29,6 +29,7 @@ #include <libc-lock.h> #include <kernel-features.h> #include <scratch_buffer.h> +#include <nss_files.h> NSS_DECLARE_MODULE_FUNCTIONS (compat) @@ -122,13 +123,10 @@ internal_setgrent (ent_t *ent) else ent->blacklist.current = 0; - ent->stream = fopen ("/etc/group", "rme"); + ent->stream = __nss_files_fopen ("/etc/group"); if (ent->stream == NULL) status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; - else - /* We take care of locking ourself. */ - __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); return status; } |