]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Generalize request_enc_pa_rep() in get_in_tkt.c
authorAndreas Schneider <asn@samba.org>
Tue, 1 Dec 2015 17:41:17 +0000 (18:41 +0100)
committerGreg Hudson <ghudson@mit.edu>
Wed, 27 Apr 2016 19:04:58 +0000 (15:04 -0400)
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]

src/lib/krb5/krb/get_in_tkt.c

index ba635fe3b5f43ac6a5c222efa92c033306573893..6ddfa4ca9aba7acba36c7d7c81e7268c8f740236 100644 (file)
@@ -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,