From: Theodore Tso Date: Wed, 26 Aug 1992 21:15:37 +0000 (+0000) Subject: Fixed some saber bugs... X-Git-Tag: krb5-1.0-beta2~91 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ba5349f9ff592e00d8797930fef580947f48745;p=krb5.git Fixed some saber bugs... git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2371 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/copy_addrs.c b/src/lib/krb5/krb/copy_addrs.c index 9520ad7ea..3f85522b4 100644 --- a/src/lib/krb5/krb/copy_addrs.c +++ b/src/lib/krb5/krb/copy_addrs.c @@ -63,16 +63,17 @@ krb5_address ***outaddr; { krb5_error_code retval; krb5_address ** tempaddr; - register int nelems; + register int nelems = 0; - for (nelems = 0; inaddr[nelems]; nelems++); + while (inaddr[nelems]) nelems++; /* one more for a null terminated list */ if (!(tempaddr = (krb5_address **) calloc(nelems+1, sizeof(*tempaddr)))) return ENOMEM; for (nelems = 0; inaddr[nelems]; nelems++) - if (retval = krb5_copy_addr(inaddr[nelems], &tempaddr[nelems])) { + retval = krb5_copy_addr(inaddr[nelems], &tempaddr[nelems]); + if (retval) { krb5_free_addresses(tempaddr); return retval; } @@ -94,16 +95,16 @@ krb5_address ***outaddr; krb5_error_code retval; krb5_address ** tempaddr; krb5_address ** tempaddr2; - register int nelems; - register int norigelems; + register int nelems = 0; + register int norigelems = 0; if (!inaddr) return 0; tempaddr2 = *outaddr; - for (nelems = 0; inaddr[nelems]; nelems++); - for (norigelems = 0; tempaddr2[norigelems]; norigelems++); + while (inaddr[nelems]) nelems++; + while (tempaddr2[norigelems]) norigelems++; tempaddr = realloc((char *)*outaddr, (nelems + norigelems + 1) * sizeof(*tempaddr)); @@ -114,10 +115,12 @@ krb5_address ***outaddr; *outaddr = tempaddr; - for (nelems = 0; inaddr[nelems]; nelems++) - if (retval = krb5_copy_addr(inaddr[nelems], - &tempaddr[norigelems + nelems])) + for (nelems = 0; inaddr[nelems]; nelems++) { + retval = krb5_copy_addr(inaddr[nelems], + &tempaddr[norigelems + nelems]); + if (retval) goto cleanup; + } tempaddr[norigelems + nelems] = 0; return 0; diff --git a/src/lib/krb5/krb/copy_athctr.c b/src/lib/krb5/krb/copy_athctr.c index 8f25f35a4..71ec3cd3d 100644 --- a/src/lib/krb5/krb/copy_athctr.c +++ b/src/lib/krb5/krb/copy_athctr.c @@ -46,7 +46,8 @@ krb5_authenticator **authto; return ENOMEM; *tempto = *authfrom; - if (retval = krb5_copy_principal(authfrom->client, &tempto->client)) { + retval = krb5_copy_principal(authfrom->client, &tempto->client); + if (retval) { xfree(tempto); return retval; } @@ -59,8 +60,8 @@ krb5_authenticator **authto; } if (authfrom->subkey) { - if (retval = krb5_copy_keyblock(authfrom->subkey, - &tempto->subkey)) { + retval = krb5_copy_keyblock(authfrom->subkey, &tempto->subkey); + if (retval) { xfree(tempto->subkey); krb5_free_checksum(tempto->checksum); krb5_free_principal(tempto->client); diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c index 586125213..566492089 100644 --- a/src/lib/krb5/krb/copy_auth.c +++ b/src/lib/krb5/krb/copy_auth.c @@ -63,21 +63,23 @@ krb5_authdata ***outauthdat; { krb5_error_code retval; krb5_authdata ** tempauthdat; - register int nelems; + register int nelems = 0; - for (nelems = 0; inauthdat[nelems]; nelems++); + while (inauthdat[nelems]) nelems++; /* one more for a null terminated list */ if (!(tempauthdat = (krb5_authdata **) calloc(nelems+1, sizeof(*tempauthdat)))) return ENOMEM; - for (nelems = 0; inauthdat[nelems]; nelems++) - if (retval = krb5_copy_authdatum(inauthdat[nelems], - &tempauthdat[nelems])) { + for (nelems = 0; inauthdat[nelems]; nelems++) { + retval = krb5_copy_authdatum(inauthdat[nelems], + &tempauthdat[nelems]); + if (retval) { krb5_free_authdata(tempauthdat); return retval; } + } *outauthdat = tempauthdat; return 0; diff --git a/src/lib/krb5/krb/copy_creds.c b/src/lib/krb5/krb/copy_creds.c index 40b555779..12591cdb6 100644 --- a/src/lib/krb5/krb/copy_creds.c +++ b/src/lib/krb5/krb/copy_creds.c @@ -51,21 +51,26 @@ krb5_creds **outcred; return ENOMEM; *tempcred = *incred; /* copy everything quickly */ - if (retval = krb5_copy_principal(incred->client, &tempcred->client)) + retval = krb5_copy_principal(incred->client, &tempcred->client); + if (retval) goto cleanlast; - if (retval = krb5_copy_principal(incred->server, &tempcred->server)) + retval = krb5_copy_principal(incred->server, &tempcred->server); + if (retval) goto cleanclient; - if (retval = krb5_copy_keyblock_contents(&incred->keyblock, - &tempcred->keyblock)) + retval = krb5_copy_keyblock_contents(&incred->keyblock, + &tempcred->keyblock); + if (retval) goto cleanserver; - if (retval = krb5_copy_addresses(incred->addresses, &tempcred->addresses)) + retval = krb5_copy_addresses(incred->addresses, &tempcred->addresses); + if (retval) goto cleanblock; - if (retval = krb5_copy_data(&incred->ticket, &scratch)) + retval = krb5_copy_data(&incred->ticket, &scratch); + if (retval) goto cleanaddrs; tempcred->ticket = *scratch; xfree(scratch); - if (retval = krb5_copy_data(&incred->second_ticket, - &scratch)) + retval = krb5_copy_data(&incred->second_ticket, &scratch); + if (retval) goto cleanticket; tempcred->second_ticket = *scratch;