From 2a180e32203e16c7e12d86c457d2df52e9151d2c Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 27 Mar 1990 11:54:33 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@423 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_creds.c | 74 +++++++++++++++++++++++++++++++++++ src/lib/krb5/krb/copy_data.c | 43 ++++++++++++++++++++ src/lib/krb5/krb/copy_princ.c | 49 +++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 src/lib/krb5/krb/copy_creds.c create mode 100644 src/lib/krb5/krb/copy_data.c create mode 100644 src/lib/krb5/krb/copy_princ.c diff --git a/src/lib/krb5/krb/copy_creds.c b/src/lib/krb5/krb/copy_creds.c new file mode 100644 index 000000000..46e9a1c37 --- /dev/null +++ b/src/lib/krb5/krb/copy_creds.c @@ -0,0 +1,74 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * krb5_copy_cred() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_cred_c [] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include + +#include + +#include + +#include + + +/* + * Copy credentials, allocating fresh storage where needed. + */ + +krb5_error_code +krb5_copy_cred(incred, outcred) +krb5_creds *incred, **outcred; +{ + krb5_creds *tempcred; + krb5_error_code retval; + krb5_data *scratch; + + if (!(tempcred = (krb5_creds *)malloc(sizeof(*tempcred)))) + return ENOMEM; + + *tempcred = *incred; /* copy everything quickly */ + if (retval = krb5_copy_principal(incred->client, &tempcred->client)) + goto cleanlast; + if (retval = krb5_copy_principal(incred->server, &tempcred->server)) + goto cleanclient; + if (retval = krb5_copy_keyblock(&incred->keyblock, &tempcred->keyblock)) + goto cleanserver; + if (retval = krb5_copy_data(&incred->ticket, &scratch)) + goto cleanblock; + tempcred->ticket = *scratch; + free((char *)scratch); + if (retval = krb5_copy_data(&incred->second_ticket, + &scratch)) + goto cleanticket; + + tempcred->second_ticket = *scratch; + free((char *)scratch); + + *outcred = tempcred; + return 0; + + cleanticket: + free(tempcred->ticket.data); + cleanblock: + free((char *)tempcred->keyblock.contents); + cleanserver: + krb5_free_principal(tempcred->server); + cleanclient: + krb5_free_principal(tempcred->client); + cleanlast: + free((char *)tempcred); + return retval; +} diff --git a/src/lib/krb5/krb/copy_data.c b/src/lib/krb5/krb/copy_data.c new file mode 100644 index 000000000..7a84e5f8c --- /dev/null +++ b/src/lib/krb5/krb/copy_data.c @@ -0,0 +1,43 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * krb5_copy_data() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_data_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include +#include + +/* + * Copy a data structure, with fresh allocation. + */ +krb5_error_code +krb5_copy_data(indata, outdata) +krb5_data *indata, **outdata; +{ + krb5_data *tempdata; + + if (!(tempdata = (krb5_data *)malloc(sizeof(*tempdata)))) + return ENOMEM; + + *tempdata = *indata; + if (!(tempdata->data = malloc(tempdata->length))) { + free((char *)tempdata); + return ENOMEM; + } + bcopy((char *)indata->data, (char *)tempdata->data, tempdata->length); + *outdata = tempdata; + return 0; +} diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c new file mode 100644 index 000000000..c450b90cc --- /dev/null +++ b/src/lib/krb5/krb/copy_princ.c @@ -0,0 +1,49 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * krb5_copy_principal() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_princ_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include + +#include + +/* + * Copy a principal structure, with fresh allocation. + */ +krb5_error_code +krb5_copy_principal(inprinc, outprinc) +krb5_principal inprinc, *outprinc; +{ + krb5_error_code retval; + krb5_principal tempprinc; + register int nelems; + + for (nelems = 0; inprinc[nelems]; nelems++); + + /* one more for a null terminated list */ + if (!(tempprinc = (krb5_principal) calloc(nelems+1, sizeof(krb5_data *)))) + return ENOMEM; + + for (nelems = 0; inprinc[nelems]; nelems++) + if (retval = krb5_copy_data(inprinc[nelems], &tempprinc[nelems])) { + krb5_free_principal(tempprinc); + return ENOMEM; + } + + *outprinc = tempprinc; + return 0; +} -- 2.26.2