*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Tue, 8 May 1990 15:57:39 +0000 (15:57 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Tue, 8 May 1990 15:57:39 +0000 (15:57 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@784 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/copy_auth.c [new file with mode: 0644]

diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c
new file mode 100644 (file)
index 0000000..5086146
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * krb5_copy_authdata()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_copy_auth_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <errno.h>
+
+#include <krb5/ext-proto.h>
+
+static krb5_error_code
+krb5_copy_authdatum(inad, outad)
+const krb5_authdata *inad;
+krb5_authdata **outad;
+{
+    krb5_authdata *tmpad;
+
+    if (!(tmpad = (krb5_authdata *)malloc(sizeof(*tmpad))))
+       return ENOMEM;
+    *tmpad = *inad;
+    if (!(tmpad->contents = (krb5_octet *)malloc(inad->length))) {
+       xfree(tmpad);
+       return ENOMEM;
+    }
+    bcopy((char *)inad->contents, (char *)tmpad->contents, inad->length);
+    *outad = tmpad;
+    return 0;
+}
+
+/*
+ * Copy an authdata array, with fresh allocation.
+ */
+krb5_error_code
+krb5_copy_authdata(inauthdat, outauthdat)
+krb5_authdata * const * inauthdat;
+krb5_authdata ***outauthdat;
+{
+    krb5_error_code retval;
+    krb5_authdata ** tempauthdat;
+    register int nelems;
+
+    for (nelems = 0; 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])) {
+           krb5_free_authdata(tempauthdat);
+           return retval;
+       }
+
+    *outauthdat = tempauthdat;
+    return 0;
+}