about summary refs log tree commit diff
path: root/nis/nss_compat/compat-pwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nss_compat/compat-pwd.c')
-rw-r--r--nis/nss_compat/compat-pwd.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c
index 8a1c424628..5bfff17ca5 100644
--- a/nis/nss_compat/compat-pwd.c
+++ b/nis/nss_compat/compat-pwd.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.
 
@@ -810,17 +810,15 @@ getpwent_next_file (struct passwd *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.  */
@@ -1023,17 +1021,15 @@ internal_getpwnam_r (const char *name, struct passwd *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.  */
@@ -1306,17 +1302,15 @@ internal_getpwuid_r (uid_t uid, struct passwd *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.  */