diff options
author | Greg Hudson <ghudson@mit.edu> | 2019-06-03 17:32:20 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2019-06-10 12:33:13 -0400 |
commit | 154551ad22e90d2e5f60103059fbaaadac017420 (patch) | |
tree | f4b8b57f92dd051e34fcbfe04d81c1024d251c02 /src/lib/krb5 | |
parent | 2d2222850200fd74790aaffcc5b5ce3dbfdb0017 (diff) | |
download | krb5-154551ad22e90d2e5f60103059fbaaadac017420.zip krb5-154551ad22e90d2e5f60103059fbaaadac017420.tar.gz krb5-154551ad22e90d2e5f60103059fbaaadac017420.tar.bz2 |
Use new pa-data helpers where appropriate
Diffstat (limited to 'src/lib/krb5')
-rw-r--r-- | src/lib/krb5/krb/get_in_tkt.c | 57 |
1 files changed, 14 insertions, 43 deletions
diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index 1e53d7a..dcf6663 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -402,40 +402,6 @@ make_preauth_list(krb5_context context, #define MAX_IN_TKT_LOOPS 16 -/* Add a pa-data item with the specified type and contents to *padptr. */ -static krb5_error_code -add_padata(krb5_pa_data ***padptr, krb5_preauthtype pa_type, - const void *contents, unsigned int length) -{ - size_t size = 0; - krb5_pa_data **pad = *padptr; - krb5_pa_data *pa= NULL; - if (pad) - for (size=0; pad[size]; size++); - pad = realloc(pad, sizeof(*pad)*(size+2)); - if (pad == NULL) - return ENOMEM; - *padptr = pad; - pad[size] = pad[size + 1] = NULL; - - pa = malloc(sizeof(krb5_pa_data)); - if (pa == NULL) - return ENOMEM; - pa->contents = NULL; - pa->length = length; - if (contents != NULL) { - pa->contents = malloc(length); - if (pa->contents == NULL) { - free(pa); - return ENOMEM; - } - memcpy(pa->contents, contents, length); - } - pa->pa_type = pa_type; - pad[size] = pa; - return 0; -} - /* Sort a pa_data sequence so that types named in the "preferred_preauth_types" * libdefaults entry are listed before any others. */ static krb5_error_code @@ -1300,8 +1266,8 @@ maybe_add_pac_request(krb5_context context, krb5_init_creds_context ctx) code = encode_krb5_pa_pac_req(&pac_req, &encoded); if (code) return code; - code = add_padata(&ctx->request->padata, KRB5_PADATA_PAC_REQUEST, - encoded->data, encoded->length); + code = k5_add_pa_data_from_data(&ctx->request->padata, + KRB5_PADATA_PAC_REQUEST, encoded); krb5_free_data(context, encoded); return code; } @@ -1313,6 +1279,7 @@ init_creds_step_request(krb5_context context, { krb5_error_code code; krb5_preauthtype pa_type; + krb5_data copy; struct errinfo save = EMPTY_ERRINFO; uint32_t rcode = (ctx->err_reply == NULL) ? 0 : ctx->err_reply->error; @@ -1414,21 +1381,25 @@ init_creds_step_request(krb5_context context, ctx->encoded_previous_request = NULL; } if (ctx->info_pa_permitted) { - code = add_padata(&ctx->request->padata, KRB5_PADATA_AS_FRESHNESS, - NULL, 0); + code = k5_add_empty_pa_data(&ctx->request->padata, + KRB5_PADATA_AS_FRESHNESS); if (code) goto cleanup; - code = add_padata(&ctx->request->padata, KRB5_ENCPADATA_REQ_ENC_PA_REP, - NULL, 0); + code = k5_add_empty_pa_data(&ctx->request->padata, + KRB5_ENCPADATA_REQ_ENC_PA_REP); } if (code) goto cleanup; if (ctx->subject_cert != NULL) { - code = add_padata(&ctx->request->padata, KRB5_PADATA_S4U_X509_USER, - ctx->subject_cert->data, ctx->subject_cert->length); + code = krb5int_copy_data_contents(context, ctx->subject_cert, ©); if (code) - return code; + goto cleanup; + code = k5_add_pa_data_from_data(&ctx->request->padata, + KRB5_PADATA_S4U_X509_USER, ©); + krb5_free_data_contents(context, ©); + if (code) + goto cleanup; } code = maybe_add_pac_request(context, ctx); |