Modified to use new principal type system
authorTheodore Tso <tytso@mit.edu>
Tue, 18 Aug 1992 23:19:55 +0000 (23:19 +0000)
committerTheodore Tso <tytso@mit.edu>
Tue, 18 Aug 1992 23:19:55 +0000 (23:19 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2329 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/copy_princ.c

index bff89b47e0b2d931f12aecd80c26958243b54208..8abdcbb9fbc644efad0e1449d8e124ab885f7ea0 100644 (file)
@@ -50,6 +50,8 @@ krb5_principal *outprinc;
     if (tempprinc == 0)
        return ENOMEM;
 
+    *tempprinc = *inprinc;     /* Copy all of the non-allocated pieces */
+
     nelems = krb5_princ_size(inprinc);
     tempprinc->data = malloc(nelems * sizeof(krb5_data));
 
@@ -68,7 +70,21 @@ krb5_principal *outprinc;
            free (tempprinc);
            return ENOMEM;
        }
+       memcpy(krb5_princ_component(tempprinc, i)->data,
+              krb5_princ_component(inprinc, i)->data, len);
+    }
+
+    tempprinc->realm.data =
+           malloc(tempprinc->realm.length = inprinc->realm.length);
+    if (!tempprinc->realm.data) {
+           for (i = 0; i < nelems; i++)
+                   free(krb5_princ_component(tempprinc, i)->data);
+           free(tempprinc->data);
+           free(tempprinc);
+           return ENOMEM;
     }
+    memcpy(tempprinc->realm.data, inprinc->realm.data, inprinc->realm.length);
+    
     *outprinc = tempprinc;
     return 0;
 }