From ecd643d43e93c63bc562cddcd052fe87ea8d6ad6 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Tue, 18 Aug 1992 23:19:55 +0000 Subject: [PATCH] Modified to use new principal type system git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2329 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_princ.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index bff89b47e..8abdcbb9f 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -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; } -- 2.26.2