]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_print_group_entry.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nis / nis_print_group_entry.c
index b32b3c2a37f6a988d0d9926173c4da10ef0e824d..f90f89ae0b527c1016ee26448fd399fd3b25ee92 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (c) 1997-2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <alloca.h>
 #include <string.h>
@@ -31,10 +30,6 @@ nis_print_group_entry (const_nis_name 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;
-      char **nomem_exp, **nomem_imp, **nomem_rec;
       nis_result *res;
       char *cp, *cp2;
       u_int i;
@@ -49,19 +44,25 @@ nis_print_group_entry (const_nis_name group)
        }
       res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME);
 
-      if (NIS_RES_STATUS(res) != NIS_SUCCESS)
+      if (res == NULL)
        return;
 
-      if ((NIS_RES_NUMOBJ (res) != 1) ||
-         (__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
-       return;
+      if (NIS_RES_STATUS (res) != NIS_SUCCESS
+         || NIS_RES_NUMOBJ (res) != 1
+         || __type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ)
+       {
+         nis_freeresult (res);
+         return;
+       }
 
-      mem_exp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
-      mem_imp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
-      mem_rec = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
-      nomem_exp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
-      nomem_imp = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
-      nomem_rec = alloca (sizeof (char *) * NIS_RES_NUMOBJ (res));
+      char *mem_exp[NIS_RES_NUMOBJ (res)];
+      char *mem_imp[NIS_RES_NUMOBJ (res)];
+      char *mem_rec[NIS_RES_NUMOBJ (res)];
+      char *nomem_exp[NIS_RES_NUMOBJ (res)];
+      char *nomem_imp[NIS_RES_NUMOBJ (res)];
+      char *nomem_rec[NIS_RES_NUMOBJ (res)];
+      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;
 
       for (i = 0;
           i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i)
@@ -154,13 +155,13 @@ nis_print_group_entry (const_nis_name group)
        {
          fputs (_("    Implicit nonmembers:\n"), stdout);
          for (i = 0; i < nomem_imp_cnt; ++i)
-           printf ("\t%s\n", &mem_imp[i][3]);
+           printf ("\t%s\n", &nomem_imp[i][3]);
        }
       else
        fputs (_("    No implicit nonmembers\n"), stdout);
       if (nomem_rec_cnt)
        {
-         fputs (_("    Explicit nonmembers:\n"), stdout);
+         fputs (_("    Recursive nonmembers:\n"), stdout);
          for (i = 0; i < nomem_rec_cnt; ++i)
            printf ("\t%s=n", &nomem_rec[i][2]);
        }