]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:rpc_server: Switch to using smb_krb5_princ_component()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 5 Sep 2023 04:46:17 +0000 (16:46 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 14 Sep 2023 21:35:29 +0000 (21:35 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/rpc_server/drsuapi/writespn.c

index 9e4b533365a18ea278236c2e62d261c72037164c..ac9199946c834376caac52450f078ebabe1856b2 100644 (file)
@@ -65,7 +65,7 @@ static bool writespn_check_spn(struct drsuapi_bind_state *b_state,
        krb5_context krb_ctx;
        krb5_error_code kerr;
        krb5_principal principal;
-       const krb5_data *component;
+       krb5_data component;
        const char *dns_name, *dnsHostName;
 
        /* The service principal name shouldn't be NULL */
@@ -128,8 +128,14 @@ static bool writespn_check_spn(struct drsuapi_bind_state *b_state,
                return false;
        }
 
-       component = krb5_princ_component(krb_ctx, principal, 1);
-       dns_name = (const char *)component->data;
+       kerr = smb_krb5_princ_component(krb_ctx, principal, 1, &component);
+       if (kerr) {
+               krb5_free_principal(krb_ctx, principal);
+               krb5_free_context(krb_ctx);
+               talloc_free(tmp_ctx);
+               return false;
+       }
+       dns_name = (const char *)component.data;
 
        if (strcasecmp(dns_name, dnsHostName) != 0) {
                krb5_free_principal(krb_ctx, principal);