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