From: Samuel Cabrero Date: Thu, 26 May 2022 11:44:17 +0000 (+0200) Subject: s3:net: Refactor net_ads_enctypes_list(), allocate a talloc context X-Git-Tag: tevent-0.13.0~252 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b04ae0d3c1bfe86ffe6332635c8d5d320dcbe06;p=thirdparty%2Fsamba.git s3:net: Refactor net_ads_enctypes_list(), allocate a talloc context ADS_STRUCT will be allocated in the talloc context. Signed-off-by: Samuel Cabrero Reviewed-by: Jeremy Allison --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 863bccb2cf1..bd75c854f6d 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -3595,11 +3595,12 @@ static void net_ads_enctype_dump_enctypes(const char *username, static int net_ads_enctypes_list(struct net_context *c, int argc, const char **argv) { - int ret = -1; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); ADS_STATUS status; ADS_STRUCT *ads = NULL; LDAPMessage *res = NULL; const char *str = NULL; + int ret = -1; if (c->display_usage || (argc < 1)) { d_printf( "%s\n" @@ -3607,27 +3608,27 @@ static int net_ads_enctypes_list(struct net_context *c, int argc, const char **a " %s\n", _("Usage:"), _("List supported enctypes")); + TALLOC_FREE(tmp_ctx); return 0; } status = ads_startup(c, false, &ads); if (!ADS_ERR_OK(status)) { - printf("startup failed\n"); - return ret; + goto out; } ret = net_ads_enctype_lookup_account(c, ads, argv[0], &res, &str); if (ret) { - goto done; + goto out; } net_ads_enctype_dump_enctypes(argv[0], str); ret = 0; - done: + out: ads_msgfree(ads, res); ads_destroy(&ads); - + TALLOC_FREE(tmp_ctx); return ret; }