Check that enctypes are valid/enabled before trying to request them

This commit is contained in:
Love Hornquist Astrand
2009-10-05 19:17:11 -07:00
parent 0d10dfb529
commit 753e2cc925

View File

@@ -1087,6 +1087,12 @@ krb5_get_credentials_with_flags(krb5_context context,
krb5_creds *res_creds; krb5_creds *res_creds;
int i; int i;
if (in_creds->session.keytype) {
ret = krb5_enctype_valid(context, in_creds->session.keytype);
if (ret)
return ret;
}
*out_creds = NULL; *out_creds = NULL;
res_creds = calloc(1, sizeof(*res_creds)); res_creds = calloc(1, sizeof(*res_creds));
if (res_creds == NULL) { if (res_creds == NULL) {
@@ -1282,6 +1288,12 @@ krb5_get_creds(krb5_context context,
krb5_creds *res_creds; krb5_creds *res_creds;
int i; int i;
if (opt && opt->enctype) {
ret = krb5_enctype_valid(context, opt->enctype);
if (ret)
return ret;
}
memset(&in_creds, 0, sizeof(in_creds)); memset(&in_creds, 0, sizeof(in_creds));
in_creds.server = rk_UNCONST(inprinc); in_creds.server = rk_UNCONST(inprinc);
@@ -1289,7 +1301,10 @@ krb5_get_creds(krb5_context context,
if (ret) if (ret)
return ret; return ret;
if (opt)
options = opt->options; options = opt->options;
else
options = 0;
flags.i = 0; flags.i = 0;
*out_creds = NULL; *out_creds = NULL;
@@ -1301,7 +1316,7 @@ krb5_get_creds(krb5_context context,
return ENOMEM; return ENOMEM;
} }
if (opt->enctype) { if (opt && opt->enctype) {
in_creds.session.keytype = opt->enctype; in_creds.session.keytype = opt->enctype;
options |= KRB5_TC_MATCH_KEYTYPE; options |= KRB5_TC_MATCH_KEYTYPE;
} }
@@ -1312,7 +1327,7 @@ krb5_get_creds(krb5_context context,
*/ */
ret = krb5_cc_retrieve_cred(context, ret = krb5_cc_retrieve_cred(context,
ccache, ccache,
opt->enctype ? KRB5_TC_MATCH_KEYTYPE : 0, options & KRB5_TC_MATCH_KEYTYPE,
&in_creds, res_creds); &in_creds, res_creds);
/* /*
* If we got a credential, check if credential is expired before * If we got a credential, check if credential is expired before