summary refs log tree commit diff
path: root/nis/nss_compat/compat-grp.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nss_compat/compat-grp.c')
-rw-r--r--nis/nss_compat/compat-grp.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c
index 4b873d6915..dab1b5e566 100644
--- a/nis/nss_compat/compat-grp.c
+++ b/nis/nss_compat/compat-grp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -458,17 +458,15 @@ getgrent_next_file (struct group *result, ent_t *ent,
       do
 	{
 	  fgetpos (ent->stream, &pos);
+	  buffer[buflen - 1] = '\xff';
 	  p = fgets (buffer, buflen, ent->stream);
-	  if (p == NULL)
+	  if (p == NULL && feof (ent->stream))
+	    return NSS_STATUS_NOTFOUND;
+	  if (p == NULL || buffer[buflen - 1] != '\xff')
 	    {
-	      if (feof (ent->stream))
-		return NSS_STATUS_NOTFOUND;
-	      else
-		{
-		  fsetpos (ent->stream, &pos);
-		  *errnop = ERANGE;
-		  return NSS_STATUS_TRYAGAIN;
-		}
+	      fsetpos (ent->stream, &pos);
+	      *errnop = ERANGE;
+	      return NSS_STATUS_TRYAGAIN;
 	    }
 
 	  /* Terminate the line for any case.  */
@@ -600,17 +598,15 @@ internal_getgrnam_r (const char *name, struct group *result, ent_t *ent,
       do
 	{
 	  fgetpos (ent->stream, &pos);
+	  buffer[buflen - 1] = '\xff';
 	  p = fgets (buffer, buflen, ent->stream);
-	  if (p == NULL)
+	  if (p == NULL && feof (ent->stream))
+	    return NSS_STATUS_NOTFOUND;
+	  if (p == NULL || buffer[buflen - 1] != '\xff')
 	    {
-	      if (feof (ent->stream))
-		return NSS_STATUS_NOTFOUND;
-	      else
-		{
-		  fsetpos (ent->stream, &pos);
-		  *errnop = ERANGE;
-		  return NSS_STATUS_TRYAGAIN;
-		}
+	      fsetpos (ent->stream, &pos);
+	      *errnop = ERANGE;
+	      return NSS_STATUS_TRYAGAIN;
 	    }
 
 	  /* Terminate the line for any case.  */
@@ -794,17 +790,15 @@ internal_getgrgid_r (gid_t gid, struct group *result, ent_t *ent,
       do
 	{
 	  fgetpos (ent->stream, &pos);
+	  buffer[buflen - 1] = '\xff';
 	  p = fgets (buffer, buflen, ent->stream);
-	  if (p == NULL)
+	  if (p == NULL && feof (ent->stream))
+	    return NSS_STATUS_NOTFOUND;
+	  if (p == NULL || buffer[buflen - 1] != '\xff')
 	    {
-	      if (feof (ent->stream))
-		return NSS_STATUS_NOTFOUND;
-	      else
-		{
-		  fsetpos (ent->stream, &pos);
-		  *errnop = ERANGE;
-		  return NSS_STATUS_TRYAGAIN;
-		}
+	      fsetpos (ent->stream, &pos);
+	      *errnop = ERANGE;
+	      return NSS_STATUS_TRYAGAIN;
 	    }
 
 	  /* Terminate the line for any case.  */