From: Andreas Schneider Date: Tue, 1 Dec 2015 17:41:17 +0000 (+0100) Subject: Generalize request_enc_pa_rep() in get_in_tkt.c X-Git-Tag: krb5-1.15-beta1~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91bb3a49f9964eaa21e4ed860fffc6b623d4313b;p=thirdparty%2Fkrb5.git Generalize request_enc_pa_rep() in get_in_tkt.c In get_in_tkt.c, rename request_enc_pa_rep() to add_padata() and add pa_type, octets, and length parameters. [ghudson@mit.edu: used a shorter function name and added a comment; rewrote commit message] --- diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index ba635fe3b5..6ddfa4ca9a 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -333,8 +333,10 @@ 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 -request_enc_pa_rep(krb5_pa_data ***padptr) +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; @@ -350,8 +352,16 @@ request_enc_pa_rep(krb5_pa_data ***padptr) if (pa == NULL) return ENOMEM; pa->contents = NULL; - pa->length = 0; - pa->pa_type = KRB5_ENCPADATA_REQ_ENC_PA_REP; + 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; *padptr = pad; return 0; @@ -1264,8 +1274,10 @@ init_creds_step_request(krb5_context context, } if (ctx->request->padata) ctx->sent_nontrivial_preauth = TRUE; - if (ctx->enc_pa_rep_permitted) - code = request_enc_pa_rep(&ctx->request->padata); + if (ctx->enc_pa_rep_permitted) { + code = add_padata(&ctx->request->padata, KRB5_ENCPADATA_REQ_ENC_PA_REP, + NULL, 0); + } if (code) goto cleanup; code = krb5int_fast_prep_req(context, ctx->fast_state,