krb5 commit: Generalize request_enc_pa_rep() in get_in_tkt.c
Greg Hudson
ghudson at mit.edu
Wed Apr 27 17:02:10 EDT 2016
https://github.com/krb5/krb5/commit/91bb3a49f9964eaa21e4ed860fffc6b623d4313b
commit 91bb3a49f9964eaa21e4ed860fffc6b623d4313b
Author: Andreas Schneider <asn at samba.org>
Date: Tue Dec 1 18:41:17 2015 +0100
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 at mit.edu: used a shorter function name and added a comment;
rewrote commit message]
src/lib/krb5/krb/get_in_tkt.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c
index ba635fe..6ddfa4c 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,
More information about the cvs-krb5
mailing list