1 commit 32c76b63be605d12314e0c6ac2bd702c883d1423
2 Author: Andreas Schwab <schwab@redhat.com>
3 Date: Mon Sep 26 17:49:14 2011 +0200
5 Correctly reparse group line after enlarging the buffer
7 diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
8 index 113abf2..c343b35 100644
9 --- a/nss/nss_files/files-initgroups.c
10 +++ b/nss/nss_files/files-initgroups.c
11 @@ -52,8 +52,10 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
12 gid_t *groups = *groupsp;
14 /* We have to iterate over the entire file. */
15 - while (!feof_unlocked (stream))
19 + fgetpos (stream, &pos);
20 ssize_t n = getline (&line, &linelen, stream);
23 @@ -64,9 +66,8 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
28 - while ((res = _nss_files_parse_grent (line, &grp, buffer, buflen,
30 + int res = _nss_files_parse_grent (line, &grp, buffer, buflen, errnop);
33 size_t newbuflen = 2 * buflen;
34 if (buffer_use_malloc || ! __libc_use_alloca (buflen + newbuflen))
35 @@ -85,6 +86,9 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
38 buffer = extend_alloca (buffer, buflen, newbuflen);
39 + /* Reread current line, the parser has clobbered it. */
40 + fsetpos (stream, &pos);
44 if (res > 0 && grp.gr_gid != group)