check return copy_Realm, copy_PrincipalName, copy_EncryptionKey

The ASN.1 functions copy_Realm(), copy_PrincipalName() and
copy_EncryptionKey() can fail.  Check the return and perform error
handling as appropriate.

Change-Id: I2b3629d19db96eb41d1cd554cef1dca99745e753
This commit is contained in:
Jeffrey Altman
2017-04-29 15:22:23 -04:00
parent cb1ab5b5fc
commit 6f3ab01c75
6 changed files with 53 additions and 17 deletions

View File

@@ -355,11 +355,17 @@ krb5_get_forwarded_creds (krb5_context context,
krb_cred_info = enc_krb_cred_part.ticket_info.val;
copy_EncryptionKey (&out_creds->session, &krb_cred_info->key);
ret = copy_EncryptionKey (&out_creds->session, &krb_cred_info->key);
if (ret)
goto out4;
ALLOC(krb_cred_info->prealm, 1);
copy_Realm (&out_creds->client->realm, krb_cred_info->prealm);
ret = copy_Realm (&out_creds->client->realm, krb_cred_info->prealm);
if (ret)
goto out4;
ALLOC(krb_cred_info->pname, 1);
copy_PrincipalName(&out_creds->client->name, krb_cred_info->pname);
ret = copy_PrincipalName(&out_creds->client->name, krb_cred_info->pname);
if (ret)
goto out4;
ALLOC(krb_cred_info->flags, 1);
*krb_cred_info->flags = out_creds->flags.b;
ALLOC(krb_cred_info->authtime, 1);
@@ -371,11 +377,17 @@ krb5_get_forwarded_creds (krb5_context context,
ALLOC(krb_cred_info->renew_till, 1);
*krb_cred_info->renew_till = out_creds->times.renew_till;
ALLOC(krb_cred_info->srealm, 1);
copy_Realm (&out_creds->server->realm, krb_cred_info->srealm);
ret = copy_Realm (&out_creds->server->realm, krb_cred_info->srealm);
if (ret)
goto out4;
ALLOC(krb_cred_info->sname, 1);
copy_PrincipalName (&out_creds->server->name, krb_cred_info->sname);
ret = copy_PrincipalName (&out_creds->server->name, krb_cred_info->sname);
if (ret)
goto out4;
ALLOC(krb_cred_info->caddr, 1);
copy_HostAddresses (&out_creds->addresses, krb_cred_info->caddr);
ret = copy_HostAddresses (&out_creds->addresses, krb_cred_info->caddr);
if (ret)
goto out4;
krb5_free_creds (context, out_creds);