* lib/krb5/krb/copy_creds.c (krb5int_copy_creds_contents): New function, split
authorKen Raeburn <raeburn@mit.edu>
Thu, 28 Dec 2006 01:51:02 +0000 (01:51 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 28 Dec 2006 01:51:02 +0000 (01:51 +0000)
out from krb5_copy_creds.
(krb5_copy_creds): Call it.
* include/k5-int.h (krb5int_copy_creds_contents): Declare.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19017 dc483132-0cff-0310-8789-dd5450dbe970

src/include/k5-int.h
src/lib/krb5/krb/copy_creds.c

index e18020fe42074280dd5c9ceffb7ffc871290de2e..ee1c9c280ee898e31fe2464c304e42442effc37a 100644 (file)
@@ -1017,6 +1017,9 @@ void krb5_free_etype_info
 krb5_error_code
 krb5int_copy_data_contents (krb5_context, const krb5_data *, krb5_data *);
 
+krb5_error_code
+krb5int_copy_creds_contents (krb5_context, const krb5_creds *, krb5_creds *);
+
 typedef krb5_error_code (*krb5_gic_get_as_key_fct)
     (krb5_context,
                     krb5_principal,
index 9f1429c08ea46894c544f7e6aa01b33253b4b815..9fdf9a67d71ada0f9690c03984769fd475b308d1 100644 (file)
@@ -38,11 +38,31 @@ krb5_copy_creds(krb5_context context, const krb5_creds *incred, krb5_creds **out
 {
     krb5_creds *tempcred;
     krb5_error_code retval;
-    krb5_data *scratch;
 
     if (!(tempcred = (krb5_creds *)malloc(sizeof(*tempcred))))
        return ENOMEM;
 
+    retval = krb5int_copy_creds_contents(context, incred, tempcred);
+    if (retval)
+       free(tempcred);
+    else
+       *outcred = tempcred;
+    return retval;
+}
+
+/*
+ * Copy contents of input credentials structure to supplied
+ * destination, allocating storage for indirect fields as needed.  On
+ * success, the output is a deep copy of the input.  On error, the
+ * output structure is garbage and its contents should be ignored.
+ */
+krb5_error_code
+krb5int_copy_creds_contents(krb5_context context, const krb5_creds *incred,
+                           krb5_creds *tempcred)
+{
+    krb5_error_code retval;
+    krb5_data *scratch;
+
     *tempcred = *incred;
     retval = krb5_copy_principal(context, incred->client, &tempcred->client);
     if (retval)
@@ -73,7 +93,6 @@ krb5_copy_creds(krb5_context context, const krb5_creds *incred, krb5_creds **out
     if (retval)
         goto clearticket;
 
-    *outcred = tempcred;
     return 0;
 
  clearticket: