aboutsummaryrefslogtreecommitdiff
path: root/nis/nss_compat
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nss_compat')
-rw-r--r--nis/nss_compat/compat-grp.c50
-rw-r--r--nis/nss_compat/compat-pwd.c50
-rw-r--r--nis/nss_compat/compat-spwd.c26
3 files changed, 61 insertions, 65 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. */
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. */
diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c
index 83db85620e..816e9c1f0a 100644
--- a/nis/nss_compat/compat-spwd.c
+++ b/nis/nss_compat/compat-spwd.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.
@@ -761,12 +761,16 @@ getspent_next_file (struct spwd *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;
-
- /* Terminate the line for any case. */
- buffer[buflen - 1] = '\0';
+ if (p == NULL || buffer[buflen - 1] != '\xff')
+ {
+ fsetpos (ent->stream, &pos);
+ *errnop = ERANGE;
+ return NSS_STATUS_TRYAGAIN;
+ }
/* Skip leading blanks. */
while (isspace (*p))
@@ -965,12 +969,16 @@ internal_getspnam_r (const char *name, struct spwd *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;
-
- /* Terminate the line for any case. */
- buffer[buflen - 1] = '\0';
+ if (p == NULL || buffer[buflen - 1] != '\xff')
+ {
+ fsetpos (ent->stream, &pos);
+ *errnop = ERANGE;
+ return NSS_STATUS_TRYAGAIN;
+ }
/* Skip leading blanks. */
while (isspace (*p))