From 2242b5bc5b3ac4e5c7b7f324e069ab638814f4a8 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Thu, 3 Jan 2019 16:51:18 +1100 Subject: [PATCH] gssapi: gss_krb5_set_allowable_enctypes prototype mismatch gss_krb5_set_allowable_enctypes() was declared with an array of int32_t types representing the enctype list, but the definition had an array of krb5_enctype. Whilst these are likely the same size, they may not be. On the receiving end, allocate an array of krb5_enctype. --- lib/gssapi/krb5/set_cred_option.c | 9 +++++---- lib/gssapi/mech/gss_krb5.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/gssapi/krb5/set_cred_option.c b/lib/gssapi/krb5/set_cred_option.c index bd3871675..1411f8665 100644 --- a/lib/gssapi/krb5/set_cred_option.c +++ b/lib/gssapi/krb5/set_cred_option.c @@ -149,8 +149,9 @@ allowed_enctypes(OM_uint32 *minor_status, goto out; } + /* serialized as int32_t[], but stored as krb5_enctype[] */ len = value->length / 4; - enctypes = malloc((len + 1) * 4); + enctypes = malloc((len + 1) * sizeof(krb5_enctype)); if (enctypes == NULL) { *minor_status = ENOMEM; major_stat = GSS_S_FAILURE; @@ -165,9 +166,9 @@ allowed_enctypes(OM_uint32 *minor_status, } for (i = 0; i < len; i++) { - uint32_t e; + int32_t e; - ret = krb5_ret_uint32(sp, &e); + ret = krb5_ret_int32(sp, &e); if (ret) { *minor_status = ret; major_stat = GSS_S_FAILURE; @@ -175,7 +176,7 @@ allowed_enctypes(OM_uint32 *minor_status, } enctypes[i] = e; } - enctypes[i] = 0; + enctypes[i] = KRB5_ENCTYPE_NULL; if (cred->enctypes) free(cred->enctypes); diff --git a/lib/gssapi/mech/gss_krb5.c b/lib/gssapi/mech/gss_krb5.c index 4f16761e8..4416d5181 100644 --- a/lib/gssapi/mech/gss_krb5.c +++ b/lib/gssapi/mech/gss_krb5.c @@ -433,7 +433,7 @@ GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status, gss_cred_id_t cred, OM_uint32 num_enctypes, - krb5_enctype *enctypes) + int32_t *enctypes) { krb5_error_code ret; OM_uint32 maj_status;