Fix direct access to krb5_principal structure
authorSimo Sorce <idra@samba.org>
Wed, 2 May 2012 17:22:08 +0000 (13:22 -0400)
committerSimo Sorce <idra@samba.org>
Fri, 4 May 2012 14:51:29 +0000 (16:51 +0200)
source4/rpc_server/drsuapi/writespn.c

index 63fdef21f599a9300d58773dc07c95326c9e094e..ccf612be5683d7ffefa182270aa8c3d91399683c 100644 (file)
@@ -57,6 +57,7 @@ static bool writespn_check_spn(struct drsuapi_bind_state *b_state,
        krb5_context krb_ctx;
        krb5_error_code kerr;
        krb5_principal principal;
+       krb5_data *component;
        const char *dns_name, *dnsHostName;
 
        /* The service principal name shouldn't be NULL */
@@ -112,14 +113,15 @@ static bool writespn_check_spn(struct drsuapi_bind_state *b_state,
                return false;
        }
 
-       if (principal->name.name_string.len != 2) {
+       if (krb5_princ_size(krb_ctx, principal) != 2) {
                krb5_free_principal(krb_ctx, principal);
                krb5_free_context(krb_ctx);
                talloc_free(tmp_ctx);
                return false;
        }
 
-       dns_name = principal->name.name_string.val[1];
+       component = krb5_princ_component(krb_ctx, principal, 1);
+       dns_name = (const char *)component->data;
 
        if (strcasecmp(dns_name, dnsHostName) != 0) {
                krb5_free_principal(krb_ctx, principal);