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
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.
$(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
--- /dev/null
+/*
+ * 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);
+}
+
case REALM_SEP:
case '\0':
*q++ = '\\';
- *q++ = '0';
+ *q++ = *cp;
break;
case '\\':
*q++ = '\\';
/* 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) {
/* 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 */