Makefile.in: Build the new test driver (t_walk_rtree.c) for
authorTheodore Tso <tytso@mit.edu>
Thu, 1 Dec 1994 01:37:13 +0000 (01:37 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 1 Dec 1994 01:37:13 +0000 (01:37 +0000)
krb5_walk_realm_tree.

walk_realm_tree.c (krb5_walk_realm_tree): Fix bug which occured when
the client or the server is a subdomain of the other; walk_realm_tree
would return the wrong answer, and suffer from memory access errors.

unparse.c (krb5_unparse_name_ext): Quote the '/' and '@' characters properly.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4724 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/Makefile.in
src/lib/krb5/krb/t_walk_rtree.c [new file with mode: 0644]
src/lib/krb5/krb/unparse.c
src/lib/krb5/krb/walk_rtree.c

index 0af7fb8afc1874bcb0e8ad8b0fee790f44573b61..63d8dd5c3d12789056e78b185b59a1f141125d54 100644 (file)
@@ -1,5 +1,16 @@
 Wed Nov 30 17:10:39 1994  Theodore Y. Ts'o  (tytso@dcl)
 
+        * Makefile.in: Build new test driver (t_walk_rtree) for
+               krb5_walk_realm_tree.
+
+       * walk_realm_tree.c (krb5_walk_realm_tree): Fix bug which occured
+               when the client or the server is a subdomain of the other;
+               walk_realm_tree would return the wrong answer, and suffer
+               from memory access errors.
+
+       * unparse.c (krb5_unparse_name_ext): Quote the '/' and '@'
+               characters properly.
+
        * configure.in: Add appropriate help text for the --with-krb4
                option.  Remove ISODE_DEFS call, since ISODE_INCLUDES now
                defines ISODE automatically.
index ed9dede43b4d63c187cd1e409ed23ef54d03b0bf..bf177075404913cb9d35d72c92aa50086b5b4cd3 100644 (file)
@@ -130,3 +130,18 @@ SRCS=      $(srcdir)/addr_comp.c   \
        $(srcdir)/tgtname.c     \
        $(srcdir)/unparse.c     \
        $(srcdir)/walk_rtree.c
+
+COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a
+
+T_WALK_RTREE_OBJS= t_walk_rtree.o walk_rtree.o tgtname.o unparse.o \
+       free_rtree.o bld_pr_ext.o $(COMERRLIB) $(TOPLIBD)/libkrb5.a
+
+t_walk_rtree: $(T_WALK_RTREE_OBJS)
+       $(CC) -o t_walk_rtree $(T_WALK_RTREE_OBJS)
+
+TEST_PROGS= t_walk_rtree
+
+check:: $(TEST_PROGS)
+
+clean::
+       $(RM) t_walk_rtree t_walk_rtree.o
diff --git a/src/lib/krb5/krb/t_walk_rtree.c b/src/lib/krb5/krb/t_walk_rtree.c
new file mode 100644 (file)
index 0000000..b033b36
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * t_walk_rtree.c --- test krb5_walk_realm_tree
+ */
+
+#include <stdio.h>
+#include <com_err.h>
+
+#include <krb5/krb5.h>
+
+main(argc, argv)
+       int     argc;
+       char    **argv;
+{
+       krb5_data client, server;
+       char    realm_branch_char = '.';
+       krb5_principal *tree, *p;
+       char *name;
+       krb5_error_code retval;
+       
+       krb5_init_ets();
+       
+       if (argc < 3 && argc > 4) {
+               fprintf(stderr,
+                       "Usage: %s client-realm server-realm [sep_char]\n",
+                       argv[0]);
+               exit(99);
+       }
+       client.data = argv[1];
+       client.length = strlen(client.data);
+
+       server.data = argv[2];
+       server.length = strlen(server.data);
+
+       if (argc == 4)
+               realm_branch_char = argv[3][0];
+
+       retval = krb5_walk_realm_tree(&client, &server, &tree,
+                                     realm_branch_char);
+       if (retval) {
+               com_err("krb5_walk_realm_tree", retval, "");
+               exit(1);
+       }
+
+       for (p = tree; *p; p++) {
+               retval = krb5_unparse_name(*p, &name);
+               if (retval) {
+                       com_err("krb5_unprase_name", retval, "");
+                       exit(2);
+               }
+               printf("%s\n", name);
+               free(name);
+       }
+
+       krb5_free_realm_tree(tree);
+
+       exit(0);
+}
+
index e8ac21ebfe1cb57c4ee8f4c7680098133a0751df..39380ef201c85331b53eb87274cf399e6eddd7ba 100644 (file)
@@ -121,7 +121,7 @@ int *size;
                    case REALM_SEP:
                    case '\0':
                        *q++ = '\\';
-                       *q++ = '0';
+                       *q++ = *cp;
                        break;
                    case '\\':
                        *q++ = '\\';
index 4ff94b9933a27cb58daf5e5718c2a8b96230fe74..0890f94d8d4b2343068593f90116a8c2eca86ca0 100644 (file)
@@ -84,6 +84,7 @@ char realm_branch_char;
            /* one is a subdomain of the other */
            com_cdot = client->data;
            com_sdot = scp;
+           nocommon = 0;
        } /* else normal case of two sharing parents */
     }
     if (!slen) {
@@ -92,6 +93,7 @@ char realm_branch_char;
            /* one is a subdomain of the other */
            com_sdot = server->data;
            com_cdot = ccp;
+           nocommon = 0;
        } /* else normal case of two sharing parents */
     }
     /* determine #links to/from common ancestor */