summaryrefslogtreecommitdiff
path: root/nis/nss_nisplus/nisplus-proto.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nss_nisplus/nisplus-proto.c')
-rw-r--r--nis/nss_nisplus/nisplus-proto.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c
index d98317a8a1..707a0e5296 100644
--- a/nis/nss_nisplus/nisplus-proto.c
+++ b/nis/nss_nisplus/nisplus-proto.c
@@ -63,7 +63,7 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto,
{
no_more_room:
__set_errno (ERANGE);
- return 0;
+ return -1;
}
strncpy (first_unused, NISENTRYVAL (0, 0, result),
NISENTRYLEN (0, 0, result));
@@ -196,8 +196,11 @@ internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer,
/* Get the next entry until we found a correct one. */
do
{
+ nis_result *saved_res;
+
if (result == NULL)
{
+ saved_res = NULL;
if (tablename_val == NULL)
if (_nss_create_tablename () != NSS_STATUS_SUCCESS)
return NSS_STATUS_UNAVAIL;
@@ -209,16 +212,30 @@ internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer,
else
{
nis_result *res;
-
+
+ saved_res = result;
res = nis_next_entry (tablename_val, &result->cookie);
- nis_freeresult (result);
result = res;
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
- return niserr2nss (result->status);
+ {
+ nis_freeresult (saved_res);
+ return niserr2nss (result->status);
+ }
}
- parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen);
+ if ((parse_res = _nss_nisplus_parse_protoent (result, proto, buffer,
+ buflen)) == -1)
+ {
+ nis_freeresult (result);
+ result = saved_res;
+ return NSS_STATUS_TRYAGAIN;
+ }
+ else
+ {
+ if (saved_res)
+ nis_freeresult (saved_res);
+ }
}
while (!parse_res);
@@ -290,13 +307,12 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
nis_freeresult (result);
+ if (parse_res == -1)
+ return NSS_STATUS_TRYAGAIN;
if (parse_res)
return NSS_STATUS_SUCCESS;
- if (!parse_res && errno == ERANGE)
- return NSS_STATUS_TRYAGAIN;
- else
- return NSS_STATUS_NOTFOUND;
+ return NSS_STATUS_NOTFOUND;
}
}
@@ -327,12 +343,13 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen);
nis_freeresult (result);
- if (parse_res)
- return NSS_STATUS_SUCCESS;
- if (!parse_res && errno == ERANGE)
+ if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
- else
- return NSS_STATUS_NOTFOUND;
+
+ if (parse_res)
+ return NSS_STATUS_SUCCESS;
+
+ return NSS_STATUS_NOTFOUND;
}
}