From a0859d051b681be050425a7324f0fb96ca1d9c62 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 1 Dec 1994 01:37:13 +0000 Subject: [PATCH] Makefile.in: Build the new test driver (t_walk_rtree.c) 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4724 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/ChangeLog | 11 +++++++ src/lib/krb5/krb/Makefile.in | 15 +++++++++ src/lib/krb5/krb/t_walk_rtree.c | 58 +++++++++++++++++++++++++++++++++ src/lib/krb5/krb/unparse.c | 2 +- src/lib/krb5/krb/walk_rtree.c | 2 ++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/lib/krb5/krb/t_walk_rtree.c diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 0af7fb8af..63d8dd5c3 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -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. diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index ed9dede43..bf1770754 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -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 index 000000000..b033b36cb --- /dev/null +++ b/src/lib/krb5/krb/t_walk_rtree.c @@ -0,0 +1,58 @@ +/* + * t_walk_rtree.c --- test krb5_walk_realm_tree + */ + +#include +#include + +#include + +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); +} + diff --git a/src/lib/krb5/krb/unparse.c b/src/lib/krb5/krb/unparse.c index e8ac21ebf..39380ef20 100644 --- a/src/lib/krb5/krb/unparse.c +++ b/src/lib/krb5/krb/unparse.c @@ -121,7 +121,7 @@ int *size; case REALM_SEP: case '\0': *q++ = '\\'; - *q++ = '0'; + *q++ = *cp; break; case '\\': *q++ = '\\'; diff --git a/src/lib/krb5/krb/walk_rtree.c b/src/lib/krb5/krb/walk_rtree.c index 4ff94b993..0890f94d8 100644 --- a/src/lib/krb5/krb/walk_rtree.c +++ b/src/lib/krb5/krb/walk_rtree.c @@ -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 */ -- 2.26.2