]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2020-25719 mit_samba: Create the talloc context earlier
authorAndreas Schneider <asn@samba.org>
Mon, 9 Aug 2021 15:25:53 +0000 (17:25 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Nov 2021 09:52:12 +0000 (10:52 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/kdc/mit_samba.c

index d11e1640ee980b2fe81793c7ac4054af96aa05fa..d0e68ec8ea494d3bc84911330b919cb0511c5d92 100644 (file)
@@ -502,6 +502,12 @@ krb5_error_code mit_samba_reget_pac(struct mit_samba_context *ctx,
        krb5_pac new_pac = NULL;
        bool ok;
 
+       /* Create a memory context early so code can use talloc_stackframe() */
+       tmp_ctx = talloc_named(ctx, 0, "mit_samba_reget_pac context");
+       if (tmp_ctx == NULL) {
+               return ENOMEM;
+       }
+
        if (client != NULL) {
                client_skdc_entry =
                        talloc_get_type_abort(client->e_data,
@@ -509,7 +515,8 @@ krb5_error_code mit_samba_reget_pac(struct mit_samba_context *ctx,
        }
 
        if (server == NULL) {
-               return EINVAL;
+               code = EINVAL;
+               goto done;
        }
 
        server_skdc_entry =
@@ -519,21 +526,18 @@ krb5_error_code mit_samba_reget_pac(struct mit_samba_context *ctx,
        /* The account may be set not to want the PAC */
        ok = samba_princ_needs_pac(server_skdc_entry);
        if (!ok) {
-               return EINVAL;
+               code = EINVAL;
+               goto done;
        }
 
        if (krbtgt == NULL) {
-               return EINVAL;
+               code = EINVAL;
+               goto done;
        }
        krbtgt_skdc_entry =
                talloc_get_type_abort(krbtgt->e_data,
                                      struct samba_kdc_entry);
 
-       tmp_ctx = talloc_named(ctx, 0, "mit_samba_reget_pac context");
-       if (tmp_ctx == NULL) {
-               return ENOMEM;
-       }
-
        code = samba_krbtgt_is_in_db(krbtgt_skdc_entry,
                                     &is_in_db,
                                     &is_untrusted);