diff options
Diffstat (limited to 'nis/nis_table.c')
-rw-r--r-- | nis/nis_table.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c index a92a4b64ce..f898e3c66c 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -215,6 +215,7 @@ nis_list (const_nis_name name, unsigned int flags, char *tableptr; char *tablepath = NULL; int first_try = 0; /* Do we try the old binding at first ? */ + nis_result *allres = NULL; if (res == NULL) return NULL; @@ -223,6 +224,7 @@ nis_list (const_nis_name name, unsigned int flags, { status = NIS_BADNAME; err_out: + nis_freeresult (allres); memset (res, '\0', sizeof (nis_result)); NIS_RES_STATUS (res) = status; return res; @@ -349,6 +351,7 @@ nis_list (const_nis_name name, unsigned int flags, if (names != namebuf) nis_freenames (names); nis_free_request (ibreq); + nis_freeresult (allres); return res; } if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len) @@ -392,6 +395,53 @@ nis_list (const_nis_name name, unsigned int flags, goto again; } } + else if ((flags & (FOLLOW_PATH | ALL_RESULTS)) + == (FOLLOW_PATH | ALL_RESULTS)) + { + if (allres == NULL) + { + allres = res; + res = malloc (sizeof (nis_result)); + if (res == NULL) + { + res = allres; + allres = NULL; + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_STATUS (res) = NIS_RES_STATUS (allres); + } + else + { + nis_object *objects_val + = realloc (NIS_RES_OBJECT (allres), + (NIS_RES_NUMOBJ (allres) + + NIS_RES_NUMOBJ (res)) + * sizeof (nis_object)); + if (objects_val == NULL) + { + NIS_RES_STATUS (res) = NIS_NOMEMORY; + goto fail; + } + NIS_RES_OBJECT (allres) = objects_val; + memcpy (NIS_RES_OBJECT (allres) + NIS_RES_NUMOBJ (allres), + NIS_RES_OBJECT (res), + NIS_RES_NUMOBJ (res) * sizeof (nis_object)); + NIS_RES_NUMOBJ (allres) += NIS_RES_NUMOBJ (res); + NIS_RES_NUMOBJ (res) = 0; + free (NIS_RES_OBJECT (res)); + NIS_RES_OBJECT (res) = NULL; + NIS_RES_STATUS (allres) = NIS_RES_STATUS (res); + xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res); + } + clnt_status = __follow_path (&tablepath, &tableptr, ibreq, + &bptr); + if (clnt_status != NIS_SUCCESS) + { + NIS_RES_STATUS (res) = clnt_status; + ++done; + } + } else ++done; break; @@ -485,6 +535,12 @@ nis_list (const_nis_name name, unsigned int flags, nis_free_request (ibreq); + if (allres) + { + nis_freeresult (res); + return allres; + } + return res; } libnsl_hidden_def (nis_list) |