about summary refs log tree commit diff
path: root/nis
diff options
context:
space:
mode:
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_add.c21
-rw-r--r--nis/nis_addmember.c13
-rw-r--r--nis/nis_call.c9
-rw-r--r--nis/nis_callback.c2
-rw-r--r--nis/nis_creategroup.c11
-rw-r--r--nis/nis_destroygroup.c13
-rw-r--r--nis/nis_file.c32
-rw-r--r--nis/nis_findserv.c2
-rw-r--r--nis/nis_ismember.c13
-rw-r--r--nis/nis_print.c6
-rw-r--r--nis/nis_print_group_entry.c13
-rw-r--r--nis/nis_removemember.c11
-rw-r--r--nis/nis_verifygroup.c11
-rw-r--r--nis/ypclnt.c2
14 files changed, 88 insertions, 71 deletions
diff --git a/nis/nis_add.c b/nis/nis_add.c
index 07fa0fb1e9..10b46aff18 100644
--- a/nis/nis_add.c
+++ b/nis/nis_add.c
@@ -29,8 +29,9 @@ nis_add (const_nis_name name, const nis_object *obj2)
   nis_result *res;
   nis_error status;
   struct ns_request req;
-  char buf1 [strlen (name) + 20];
-  char buf4 [strlen (name) + 20];
+  size_t namelen = strlen (name);
+  char buf1 [namelen + 20];
+  char buf4 [namelen + 20];
 
   res = calloc (1, sizeof (nis_result));
   if (res == NULL)
@@ -40,13 +41,13 @@ nis_add (const_nis_name name, const nis_object *obj2)
 
   memcpy (&obj, obj2, sizeof (nis_object));
 
-  if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
+  if (obj.zo_name == NULL || obj.zo_name[0] == '\0')
     obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
 
-  if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
+  if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0')
     obj.zo_owner = nis_local_principal ();
 
-  if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
+  if (obj.zo_group == NULL || obj.zo_group[0] == '\0')
     obj.zo_group = nis_local_group ();
 
   obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
@@ -59,11 +60,11 @@ nis_add (const_nis_name name, const nis_object *obj2)
     }
   req.ns_object.ns_object_len = 1;
 
-  if ((status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
-			      NIS_ADD, (xdrproc_t) _xdr_ns_request,
-			      (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
-			      (caddr_t) res, MASTER_ONLY,
-			      NULL)) != RPC_SUCCESS)
+  status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
+			 NIS_ADD, (xdrproc_t) _xdr_ns_request,
+			 (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
+			 (caddr_t) res, MASTER_ONLY, NULL);
+  if (status != RPC_SUCCESS)
     NIS_RES_STATUS (res) = status;
 
   nis_destroy_object (req.ns_object.ns_object_val);
diff --git a/nis/nis_addmember.c b/nis/nis_addmember.c
index 6d55bd0d07..2a31903572 100644
--- a/nis/nis_addmember.c
+++ b/nis/nis_addmember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -23,11 +23,12 @@
 nis_error
 nis_addmember (const_nis_name member, const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 14 + NIS_MAXNAMELEN];
-      char leafbuf[strlen (group) + 2];
-      char domainbuf[strlen (group) + 2];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 14 + NIS_MAXNAMELEN];
+      char leafbuf[grouplen + 2];
+      char domainbuf[grouplen + 2];
       nis_result *res, *res2;
       nis_error status;
       char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_addmember (const_nis_name member, const_nis_name group)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
         {
 	  *cp++ = '.';
           stpcpy (cp, cp2);
diff --git a/nis/nis_call.c b/nis/nis_call.c
index ff9e768fe4..a2bbdb50c0 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -484,9 +484,10 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
     case LOWER_NAME:
       {
 	directory_obj *obj;
-	char leaf [strlen (name) + 3];
-	char domain [strlen (name) + 3];
-	char ndomain [strlen (name) + 3];
+	size_t namelen = strlen (name);
+	char leaf [namelen + 3];
+	char domain [namelen + 3];
+	char ndomain [namelen + 3];
 	char *cp;
 	u_int run = 0;
 
@@ -494,7 +495,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
 
 	do
 	  {
-	    if (strlen (domain) == 0)
+	    if (domain[0] == '\0')
 	      {
 		nis_free_directory (dir);
 		return NULL;
diff --git a/nis/nis_callback.c b/nis/nis_callback.c
index 4c5693a3b5..5c8828d1fc 100644
--- a/nis/nis_callback.c
+++ b/nis/nis_callback.c
@@ -313,7 +313,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
 #else
       cb->serv->pkey.n_len =0;
       cb->serv->pkey.n_bytes = NULL;
-      cb->serv->key_type = NIS_PK_DH;
+      cb->serv->key_type = NIS_PK_NONE;
 #endif
     }
 
diff --git a/nis/nis_creategroup.c b/nis/nis_creategroup.c
index 8333e09c89..cd882ca01d 100644
--- a/nis/nis_creategroup.c
+++ b/nis/nis_creategroup.c
@@ -23,11 +23,12 @@
 nis_error
 nis_creategroup (const_nis_name group, u_long flags)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 50];
-      char leafbuf[strlen (group) + 2];
-      char domainbuf[strlen (group) + 2];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 50];
+      char leafbuf[grouplen + 2];
+      char domainbuf[grouplen + 2];
       nis_error status;
       nis_result *res;
       char *cp, *cp2;
@@ -36,7 +37,7 @@ nis_creategroup (const_nis_name group, u_long flags)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
         {
 	  *cp++ = '.';
           stpcpy (cp, cp2);
diff --git a/nis/nis_destroygroup.c b/nis/nis_destroygroup.c
index 5b70a67b68..ad56513607 100644
--- a/nis/nis_destroygroup.c
+++ b/nis/nis_destroygroup.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -23,11 +23,12 @@
 nis_error
 nis_destroygroup (const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 50];
-      char leafbuf[strlen (group) + 3];
-      char domainbuf[strlen (group) + 3];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 50];
+      char leafbuf[grouplen + 3];
+      char domainbuf[grouplen + 3];
       nis_error status;
       nis_result *res;
       char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_destroygroup (const_nis_name group)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
 	{
 	  *cp++ = '.';
 	  stpcpy (cp, cp2);
diff --git a/nis/nis_file.c b/nis/nis_file.c
index 4634e67f61..94fa4eb865 100644
--- a/nis/nis_file.c
+++ b/nis/nis_file.c
@@ -30,6 +30,7 @@ readColdStartFile (void)
 {
   XDR xdrs;
   FILE *in;
+  bool_t status;
   directory_obj obj;
 
   in = fopen (cold_start_file, "rb");
@@ -37,10 +38,11 @@ readColdStartFile (void)
     return NULL;
   memset (&obj, '\0', sizeof (obj));
   xdrstdio_create (&xdrs, in, XDR_DECODE);
-  if (!_xdr_directory_obj (&xdrs, &obj))
-    return NULL;
+  status = _xdr_directory_obj (&xdrs, &obj);
+  xdr_destroy (&xdrs);
+  fclose (in);
 
-  return nis_clone_directory (&obj, NULL);
+  return status ? nis_clone_directory (&obj, NULL) : NULL;
 }
 
 bool_t
@@ -48,16 +50,18 @@ writeColdStartFile (const directory_obj *obj)
 {
   XDR xdrs;
   FILE *out;
+  bool_t status;
 
   out = fopen (cold_start_file, "wb");
   if (out == NULL)
     return FALSE;
 
   xdrstdio_create (&xdrs, out, XDR_ENCODE);
-  if (!_xdr_directory_obj (&xdrs, (directory_obj *) obj))
-    return FALSE;
+  status = _xdr_directory_obj (&xdrs, (directory_obj *) obj);
+  xdr_destroy (&xdrs);
+  fclose (out);
 
-  return TRUE;
+  return status;
 }
 
 nis_object *
@@ -65,6 +69,7 @@ nis_read_obj (const char *name)
 {
   XDR xdrs;
   FILE *in;
+  bool_t status;
   nis_object obj;
 
   in = fopen (name, "rb");
@@ -73,10 +78,11 @@ nis_read_obj (const char *name)
 
   memset (&obj, '\0', sizeof (obj));
   xdrstdio_create (&xdrs, in, XDR_DECODE);
-  if (!_xdr_nis_object (&xdrs, &obj))
-    return NULL;
+  status =_xdr_nis_object (&xdrs, &obj);
+  xdr_destroy (&xdrs);
+  fclose (in);
 
-  return nis_clone_object (&obj, NULL);
+  return status ? nis_clone_object (&obj, NULL) : NULL;
 }
 
 bool_t
@@ -84,14 +90,16 @@ nis_write_obj (const char *name, const nis_object *obj)
 {
   XDR xdrs;
   FILE *out;
+  bool_t status;
 
   out = fopen (name, "wb");
   if (out == NULL)
     return FALSE;
 
   xdrstdio_create (&xdrs, out, XDR_ENCODE);
-  if (!_xdr_nis_object (&xdrs, (nis_object *) obj))
-    return FALSE;
+  status = _xdr_nis_object (&xdrs, (nis_object *) obj);
+  xdr_destroy (&xdrs);
+  fclose (out);
 
-  return TRUE;
+  return status;
 }
diff --git a/nis/nis_findserv.c b/nis/nis_findserv.c
index 0e9f01700d..832b6a541d 100644
--- a/nis/nis_findserv.c
+++ b/nis/nis_findserv.c
@@ -138,7 +138,7 @@ __nis_findfastest (dir_binding * bind)
       if (strcmp (bind->server_val[i].ep.ep_val[j].family, "inet") == 0)
 	if ((bind->server_val[i].ep.ep_val[j].proto == NULL) ||
 	    (strcmp (bind->server_val[i].ep.ep_val[j].proto, "-") == 0) ||
-	    (strlen (bind->server_val[i].ep.ep_val[j].proto) == 0))
+	    (bind->server_val[i].ep.ep_val[j].proto[0] == '\0'))
 	  {
 	    sin.sin_addr.s_addr =
 	      inetstr2int (bind->server_val[i].ep.ep_val[j].uaddr);
diff --git a/nis/nis_ismember.c b/nis/nis_ismember.c
index aadd19753a..4a33f02cff 100644
--- a/nis/nis_ismember.c
+++ b/nis/nis_ismember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -27,9 +27,10 @@
 static int
 internal_ismember (const_nis_name principal, const_nis_name group)
 {
-  char buf[strlen (group) + 50];
-  char leafbuf[strlen (group) + 2];
-  char domainbuf[strlen (group) + 2];
+  size_t grouplen = strlen (group);
+  char buf[grouplen + 50];
+  char leafbuf[grouplen + 2];
+  char domainbuf[grouplen + 2];
   nis_result *res;
   char *cp, *cp2;
   u_int i;
@@ -37,7 +38,7 @@ internal_ismember (const_nis_name principal, const_nis_name group)
   cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
   cp = stpcpy (cp, ".groups_dir");
   cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-  if (cp2 != NULL && strlen (cp2) > 0)
+  if (cp2 != NULL && cp2[0] != '\0')
     {
       *cp++ = '.';
       strcpy (cp, cp2);
@@ -117,7 +118,7 @@ internal_ismember (const_nis_name principal, const_nis_name group)
 bool_t
 nis_ismember (const_nis_name principal, const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0 && principal != NULL)
+  if (group != NULL && group[0] != '\0' && principal != NULL)
     return internal_ismember (principal, group) == 1 ? TRUE : FALSE;
   else
     return FALSE;
diff --git a/nis/nis_print.c b/nis/nis_print.c
index 0e36017615..b578cbfb65 100644
--- a/nis/nis_print.c
+++ b/nis/nis_print.c
@@ -202,15 +202,15 @@ nis_print_directory (const directory_obj *dir)
 	  for (j = 0; j < sptr->ep.ep_len; j++)
 	    {
 	      printf ("\t[%d] - ", j + 1);
-	      if (ptr->proto != NULL && strlen (ptr->proto) > 0)
+	      if (ptr->proto != NULL && ptr->proto[0] != '\0')
 		printf ("%s, ", ptr->proto);
 	      else
 		printf ("-, ");
-	      if (ptr->family != NULL && strlen (ptr->family) > 0)
+	      if (ptr->family != NULL && ptr->family[0] != '\0')
 		printf ("%s, ", ptr->family);
 	      else
 		printf ("-, ");
-	      if (ptr->uaddr != NULL && strlen (ptr->uaddr) > 0)
+	      if (ptr->uaddr != NULL && ptr->uaddr[0] != '\0')
 		printf ("%s\n", ptr->uaddr);
 	      else
 		fputs ("-\n", stdout);
diff --git a/nis/nis_print_group_entry.c b/nis/nis_print_group_entry.c
index fbc9ad11ba..d5cdda038c 100644
--- a/nis/nis_print_group_entry.c
+++ b/nis/nis_print_group_entry.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -23,11 +23,12 @@
 void
 nis_print_group_entry (const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 50];
-      char leafbuf[strlen (group) + 3];
-      char domainbuf[strlen (group) + 3];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 50];
+      char leafbuf[grouplen + 3];
+      char domainbuf[grouplen + 3];
       unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0;
       unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0;
       char **mem_exp, **mem_imp, **mem_rec;
@@ -39,7 +40,7 @@ nis_print_group_entry (const_nis_name group)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
 	{
 	  *cp++ = '.';
 	  stpcpy (cp, cp2);
diff --git a/nis/nis_removemember.c b/nis/nis_removemember.c
index 28050a1ac3..4fa8893a84 100644
--- a/nis/nis_removemember.c
+++ b/nis/nis_removemember.c
@@ -23,11 +23,12 @@
 nis_error
 nis_removemember (const_nis_name member, const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 14 + NIS_MAXNAMELEN];
-      char leafbuf[strlen (group) + 2];
-      char domainbuf[strlen (group) + 2];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 14 + NIS_MAXNAMELEN];
+      char leafbuf[grouplen + 2];
+      char domainbuf[grouplen + 2];
       nis_name *newmem;
       nis_result *res, *res2;
       nis_error status;
@@ -37,7 +38,7 @@ nis_removemember (const_nis_name member, const_nis_name group)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
         {
           cp = stpcpy (cp, ".");
           stpcpy (cp, cp2);
diff --git a/nis/nis_verifygroup.c b/nis/nis_verifygroup.c
index 6d3ec7b7b7..e04a8386b9 100644
--- a/nis/nis_verifygroup.c
+++ b/nis/nis_verifygroup.c
@@ -23,11 +23,12 @@
 nis_error
 nis_verifygroup (const_nis_name group)
 {
-  if (group != NULL && strlen (group) > 0)
+  if (group != NULL && group[0] != '\0')
     {
-      char buf[strlen (group) + 50];
-      char leafbuf[strlen (group) + 2];
-      char domainbuf[strlen (group) + 2];
+      size_t grouplen = strlen (group);
+      char buf[grouplen + 50];
+      char leafbuf[grouplen + 2];
+      char domainbuf[grouplen + 2];
       nis_result *res;
       nis_error status;
       char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_verifygroup (const_nis_name group)
       cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
       cp = stpcpy (cp, ".groups_dir");
       cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
-      if (cp2 != NULL && strlen (cp2) > 0)
+      if (cp2 != NULL && cp2[0] != '\0')
 	{
 	  *cp++ = '.';
 	  stpcpy (cp, cp2);
diff --git a/nis/ypclnt.c b/nis/ypclnt.c
index e8c016d028..198c4775b5 100644
--- a/nis/ypclnt.c
+++ b/nis/ypclnt.c
@@ -64,7 +64,7 @@ __yp_bind (const char *domain, dom_binding **ypdb)
   int is_new = 0;
   int try;
 
-  if ((domain == NULL) || (strlen (domain) == 0))
+  if ((domain == NULL) || (domain[0] == '\0'))
     return YPERR_BADARGS;
 
   if (ypdb != NULL)