diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | nis/nis_table.c | 37 | ||||
-rw-r--r-- | nis/ypclnt.c | 4 |
3 files changed, 22 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog index 5ef0739965..9f0e96fe63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-11-26 Ulrich Drepper <drepper@redhat.com> + * nis/nis_table.c (__create_ib_request): Use strdupa instead of + variable size array. + (RPCTIMEOUT): Mark as const. + * nis/ypclnt.c (yp_bind_ypbindprog): Initialize clnt_saddr by hand. (ypdomainname): Renamed from __ypdomainname. No need for initializer. (ypbindlist): Renamed from __ypbindlist. @@ -15,6 +19,7 @@ (yp_match, yp_next, yp_master, yp_order, yp_maplist): Use it. (yp_all): Correct test for invalid parameter. Pretty printing. + (RPCTIMEOUT, UDPTIMEOUT): Mark as const. 2005-11-25 Richard Henderson <rth@redhat.com> diff --git a/nis/nis_table.c b/nis/nis_table.c index 2531a3fbc5..27efd5181a 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -27,11 +27,9 @@ static struct ib_request * __create_ib_request (const_nis_name name, unsigned int flags) { - struct ib_request *ibreq = calloc (1, sizeof (ib_request)); - char buf[strlen (name) + 1]; + struct ib_request *ibreq = calloc (1, sizeof (struct ib_request)); nis_attr *search_val = NULL; size_t search_len = 0; - char *cptr; size_t size = 0; if (ibreq == NULL) @@ -39,7 +37,7 @@ __create_ib_request (const_nis_name name, unsigned int flags) ibreq->ibr_flags = flags; - cptr = strcpy (buf, name); + char *cptr = strdupa (name); /* Not of "[key=value,key=value,...],foo.." format? */ if (cptr[0] != '[') @@ -49,8 +47,8 @@ __create_ib_request (const_nis_name name, unsigned int flags) ibreq->ibr_name = strchr (cptr, ']'); if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',') { - ibreq->ibr_name = NULL; /* Or the xdr_* functions will dump */ - nis_free_request (ibreq); + /* The object has not really been built yet so we use free. */ + free (ibreq); return NULL; } @@ -120,17 +118,16 @@ __create_ib_request (const_nis_name name, unsigned int flags) return ibreq; } -static struct timeval RPCTIMEOUT = {10, 0}; +static const struct timeval RPCTIMEOUT = {10, 0}; static char * __get_tablepath (char *name, dir_binding *bptr) { enum clnt_stat result; - nis_result *res = calloc (1, sizeof (nis_result)); + nis_result res; struct ns_request req; - if (res == NULL) - return NULL; + memset (&res, '\0', sizeof (res)); req.ns_name = name; req.ns_object.ns_object_len = 0; @@ -138,20 +135,16 @@ __get_tablepath (char *name, dir_binding *bptr) result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request, (caddr_t) &req, (xdrproc_t) _xdr_nis_result, - (caddr_t) res, RPCTIMEOUT); + (caddr_t) &res, RPCTIMEOUT); - if (result == RPC_SUCCESS && NIS_RES_STATUS (res) == NIS_SUCCESS && - __type_of (NIS_RES_OBJECT (res)) == NIS_TABLE_OBJ) - { - char *cptr = strdup (NIS_RES_OBJECT (res)->TA_data.ta_path); - nis_freeresult (res); - return cptr; - } + char *cptr; + if (result == RPC_SUCCESS && NIS_RES_STATUS (&res) == NIS_SUCCESS + && __type_of (NIS_RES_OBJECT (&res)) == NIS_TABLE_OBJ) + cptr = NIS_RES_OBJECT (&res)->TA_data.ta_path; else - { - nis_freeresult (res); - return strdup (""); - } + cptr = ""; + + return strdup (cptr); } nis_result * diff --git a/nis/ypclnt.c b/nis/ypclnt.c index 68ab3cfa94..5fc931c459 100644 --- a/nis/ypclnt.c +++ b/nis/ypclnt.c @@ -46,8 +46,8 @@ struct dom_binding }; typedef struct dom_binding dom_binding; -static struct timeval RPCTIMEOUT = {25, 0}; -static struct timeval UDPTIMEOUT = {5, 0}; +static const struct timeval RPCTIMEOUT = {25, 0}; +static const struct timeval UDPTIMEOUT = {5, 0}; static int const MAXTRIES = 2; static char ypdomainname[NIS_MAXNAMELEN + 1]; __libc_lock_define_initialized (static, ypbindlist_lock) |