From: Swen Schillig Date: Wed, 21 Nov 2018 12:30:08 +0000 (+0100) Subject: utils: Free host realm after processing X-Git-Tag: tdb-1.3.17~675 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64fbc4c151158a1bc8864b3db56c79c4367cd7f2;p=thirdparty%2Fsamba.git utils: Free host realm after processing In case of error and at the end of processing the list of realms have to be free'd again. Signed-off-by: Swen Schillig Reviewed-by: Andreas Schneider Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Thu Nov 22 11:18:41 CET 2018 on sn-devel-144 --- diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index f94af266daa..140f9900795 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -281,6 +281,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv) krb5_context ctx; struct ip_service *kdcs; const char *realm; + char **get_host_realms = NULL; int num_kdcs = 0; int i; NTSTATUS status; @@ -298,21 +299,20 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv) } else if (lp_realm() && *lp_realm()) { realm = lp_realm(); } else { - char **realms; - - rc = krb5_get_host_realm(ctx, NULL, &realms); + rc = krb5_get_host_realm(ctx, NULL, &get_host_realms); if (rc) { DEBUG(1,("krb5_gethost_realm failed (%s)\n", error_message(rc))); krb5_free_context(ctx); return -1; } - realm = (const char *) *realms; + realm = (const char *) *get_host_realms; } status = get_kdc_list(realm, NULL, &kdcs, &num_kdcs); if (!NT_STATUS_IS_OK(status)) { DEBUG(1,("get_kdc_list failed (%s)\n", nt_errstr(status))); + krb5_free_host_realm(ctx, get_host_realms); krb5_free_context(ctx); return -1; } @@ -325,6 +325,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv) d_printf("%s:%u\n", addr, kdcs[i].port); } + krb5_free_host_realm(ctx, get_host_realms); krb5_free_context(ctx); return 0; #endif