Fixed some saber bugs...
authorTheodore Tso <tytso@mit.edu>
Wed, 26 Aug 1992 21:15:37 +0000 (21:15 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 26 Aug 1992 21:15:37 +0000 (21:15 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2371 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/copy_addrs.c
src/lib/krb5/krb/copy_athctr.c
src/lib/krb5/krb/copy_auth.c
src/lib/krb5/krb/copy_creds.c

index 9520ad7ea5870a7c4e7b3e9120d7cc3ba1577be0..3f85522b4e3df45a9c0e6fa64ed622a4a415723f 100644 (file)
@@ -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;
index 8f25f35a4d876b8e2ab6cc5b19fa0a4542a29e7b..71ec3cd3ddb859f1454eb14895b19e5f71d1e0ea 100644 (file)
@@ -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);    
index 58612521337ea9bdbb91bc32711eb561efda6c1c..56649208981eed30edebe64c523b4576ebdeda66 100644 (file)
@@ -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;
index 40b55577915b0f4be2e0b2b7e2d083d646c59fc3..12591cdb6a11de2c4c5817d1ec231bccaf614b12 100644 (file)
@@ -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;