From c2edcfc6afcdc27a007806d48707f6709418eabc Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Thu, 17 Mar 2011 22:08:22 +0000 Subject: [PATCH] Don't leak the default realm name when initializing the default realm in the KDC. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24723 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kdc/main.c b/src/kdc/main.c index 7979031e5..d58298d80 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -162,6 +162,8 @@ setup_server_realm(krb5_principal sprinc) static void finish_realm(kdc_realm_t *rdp) { + if (rdp->realm_name) + free(rdp->realm_name); if (rdp->realm_mpname) free(rdp->realm_mpname); if (rdp->realm_stash) @@ -290,7 +292,11 @@ init_realm(kdc_realm_t *rdp, char *realm, char *def_mpname, goto whoops; } - rdp->realm_name = realm; + rdp->realm_name = strdup(realm); + if (rdp->realm_name == NULL) { + kret = ENOMEM; + goto whoops; + } kret = krb5int_init_context_kdc(&rdp->realm_context); if (kret) { kdc_err(NULL, kret, "while getting context for realm %s", realm); @@ -863,6 +869,7 @@ initialize_realms(krb5_context kcontext, int argc, char **argv) kdc_realmlist[0] = rdatap; kdc_numrealms++; } + krb5_free_default_realm(kcontext, lrealm); } /* Ensure that this is set for our first request. */ -- 2.26.2