]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:net: Refactor net_ads_enctypes_list(), allocate a talloc context
authorSamuel Cabrero <scabrero@samba.org>
Thu, 26 May 2022 11:44:17 +0000 (13:44 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 27 Jun 2022 15:50:30 +0000 (15:50 +0000)
ADS_STRUCT will be allocated in the talloc context.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/utils/net_ads.c

index 863bccb2cf1cada7177c47fe9dec932acfb090da..bd75c854f6d05ef576f9e5d4e9b32c2e33063cd7 100644 (file)
@@ -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;
 }