Blame SOURCES/glibc-rh739971.patch

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