(init_tgs_req): some more error checking

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5939 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-04-11 22:53:45 +00:00
parent 5457b0d6ae
commit f6e5c6cbae

View File

@@ -142,6 +142,7 @@ init_tgs_req (krb5_context context,
t->msg_type = krb_tgs_req; t->msg_type = krb_tgs_req;
if (in_creds->session.keytype) { if (in_creds->session.keytype) {
krb5_enctype foo[2]; krb5_enctype foo[2];
foo[0] = in_creds->session.keytype; foo[0] = in_creds->session.keytype;
foo[1] = 0; foo[1] = 0;
ret = krb5_init_etype(context, ret = krb5_init_etype(context,
@@ -209,21 +210,30 @@ init_tgs_req (krb5_context context,
{ {
krb5_auth_context ac; krb5_auth_context ac;
krb5_keyblock *key; krb5_keyblock *key;
ret = krb5_auth_con_init(context, &ac); ret = krb5_auth_con_init(context, &ac);
if(ret) if(ret)
return ret; goto fail;
ret = krb5_generate_subkey (context, &krbtgt->session, &key); ret = krb5_generate_subkey (context, &krbtgt->session, &key);
if (ret) {
krb5_auth_con_free (context, ac);
goto fail;
}
ret = krb5_auth_con_setlocalsubkey(context, ac, key); ret = krb5_auth_con_setlocalsubkey(context, ac, key);
if(ret == ENOMEM) if (ret) {
/* XXX */; krb5_free_keyblock (context, key);
krb5_auth_con_free (context, ac);
goto fail;
}
if(in_creds->authdata.len){ if(in_creds->authdata.len) {
size_t len; size_t len;
unsigned char *buf; unsigned char *buf;
krb5_crypto crypto; krb5_crypto crypto;
len = length_AuthorizationData(&in_creds->authdata); len = length_AuthorizationData(&in_creds->authdata);
buf = malloc(len); buf = malloc(len);
ret = encode_AuthorizationData(buf + len - 1, len, &in_creds->authdata, &len); ret = encode_AuthorizationData(buf + len - 1,
len, &in_creds->authdata, &len);
ALLOC(t->req_body.enc_authorization_data, 1); ALLOC(t->req_body.enc_authorization_data, 1);
ret = krb5_crypto_init(context, key, 0, &crypto); ret = krb5_crypto_init(context, key, 0, &crypto);
krb5_encrypt_EncryptedData(context, krb5_encrypt_EncryptedData(context,
@@ -235,17 +245,19 @@ init_tgs_req (krb5_context context,
0, 0,
t->req_body.enc_authorization_data); t->req_body.enc_authorization_data);
krb5_crypto_destroy(context, crypto); krb5_crypto_destroy(context, crypto);
}else } else {
t->req_body.enc_authorization_data = NULL; t->req_body.enc_authorization_data = NULL;
}
ret = make_pa_tgs_req(context, ret = make_pa_tgs_req(context,
ac, ac,
&t->req_body, &t->req_body,
t->padata->val, t->padata->val,
krbtgt); krbtgt);
if(ret) if(ret) {
krb5_auth_con_free(context, ac);
goto fail; goto fail;
}
*subkey = key; *subkey = key;
krb5_auth_con_free(context, ac); krb5_auth_con_free(context, ac);