diff options
| author | John Kohl <jtkohl@mit.edu> | 1990-05-08 15:57:39 +0000 |
|---|---|---|
| committer | John Kohl <jtkohl@mit.edu> | 1990-05-08 15:57:39 +0000 |
| commit | f9c5ad7b787b022ab89c505ab8be6568b57263b1 (patch) | |
| tree | f3f7d75ccebd9376ccabb9e7f383eb62e98b727a /src/lib | |
| parent | 7784338dd173e5c382f27d8382226ead2de3c140 (diff) | |
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@784 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/krb5/krb/copy_auth.c | 71 |
1 files changed, 71 insertions, 0 deletions
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/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; +} |
