From f9c5ad7b787b022ab89c505ab8be6568b57263b1 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 8 May 1990 15:57:39 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@784 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_auth.c | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/lib/krb5/krb/copy_auth.c diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c new file mode 100644 index 000000000..5086146b2 --- /dev/null +++ b/src/lib/krb5/krb/copy_auth.c @@ -0,0 +1,71 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * krb5_copy_authdata() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_auth_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include + +#include + +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; +} -- 2.26.2