krb5_const_principal val;
register int *error;
{
-#if 0
- /* this code is for -h2 style ISODE structures. However, pepsy
- generates horribly broken when given -h2. */
-
+ register struct type_KRB5_PrincipalName *retval = 0;
+ register struct element_KRB5_6 *namestring = 0, *rv1 = 0, *rv2;
register int i;
- register struct type_KRB5_PrincipalName *retval;
-
- /* count elements */
- for (i = 0; val[i]; i++);
-
- i--; /* skip the realm */
+ int nelem = krb5_princ_size(val);
- retval = (struct type_KRB5_PrincipalName *)
- xmalloc(sizeof(*retval)+max(0,i-1)*sizeof(retval->GeneralString[0]));
+ retval = (struct type_KRB5_PrincipalName *) xmalloc(sizeof(*retval));
if (!retval) {
*error = ENOMEM;
return(0);
}
- retval->nelem = i;
- for (i = 1; i <= retval->nelem; i++) { /* still skipping realm */
- retval->GeneralString[i-1] = krb5_data2qbuf(val[i]);
- if (!retval->GeneralString[i-1]) {
- /* clean up */
- retval->nelem = i-1;
- free_KRB5_PrincipalName(retval);
- *error = ENOMEM;
- return(0);
- }
- }
- return(retval);
-
-#endif
- register struct type_KRB5_PrincipalName *retval = 0, *rv1 = 0, *rv2;
- register int i;
- int nelem = krb5_princ_size(val);
-
+
+ retval->name__type = krb5_princ_type(val);
/* still skipping realm */
for (i = 0; i < nelem; i++, rv1 = rv2) {
- rv2 = (struct type_KRB5_PrincipalName *) xmalloc(sizeof(*rv2));
+ rv2 = (struct element_KRB5_6 *) xmalloc(sizeof(*rv2));
if (!rv2) {
if (retval)
free_KRB5_PrincipalName(retval);
if (rv1)
rv1->next = rv2;
xbzero((char *)rv2, sizeof (*rv2));
- if (!retval)
- retval = rv2;
+ if (!namestring)
+ namestring = rv2;
rv2->GeneralString = krb5_data2qbuf(krb5_princ_component(val, i));
if (!rv2->GeneralString) {
return(0);
}
}
+
+ retval->name__string = namestring;
+
return(retval);
}
struct type_KRB5_PasswdData *
krb5_pwd_data2KRB5_PWD__DATA(val, error)
-register krb5_pwd_data *val;
+register const krb5_pwd_data *val;
register int *error;
{
register struct type_KRB5_PasswdData *retval = 0;
rv2 = (struct element_KRB5_7 *) xmalloc(sizeof(*rv2));
if (!rv2) {
- if (retval)
- free_KRB5_PA__DATA(retval);
+ errout:
+ while (retval) {
+ free_KRB5_PA__DATA(retval->PA__DATA);
+ rv1 = retval->next;
+ free(retval);
+ retval = rv1;
+ }
*error = ENOMEM;
return(0);
}
rv2->PA__DATA = (struct type_KRB5_PA__DATA *)
xmalloc(sizeof(*(rv2->PA__DATA)));
- if (!rv2->PA__DATA) {
- errout:
- if (retval)
- free_KRB5_PA__DATA(retval);
- *error = ENOMEM;
- return(0);
- }
+ if (!rv2->PA__DATA)
+ goto errout;
rv2->PA__DATA->padata__type = val[i]->pa_type;
rv2->PA__DATA->pa__data = str2qb((char *)(val[i])->contents,
(val[i])->length, 1);
const struct type_KRB5_Realm *realm;
register int *error;
{
-#if 0
- /* this code is for -h2 style ISODE structures. However, pepsy
- generates horribly broken when given -h2. */
-
register krb5_principal retval;
register int i;
+ register const struct element_KRB5_6 *rv;
- /* plus one for the realm, plus one for null term */
- retval = (krb5_principal) xcalloc(val->nelem + 2, sizeof(krb5_data *));
-
+ retval = (krb5_principal) malloc(sizeof(krb5_principal_data));
if (!retval) {
*error = ENOMEM;
return(0);
}
- retval[0] = qbuf2krb5_data(realm, error);
- if (!retval[0]) {
- xfree(retval);
- return(0);
- }
- for (i = 0; i < val->nelem; i++) {
- retval[i+1] = qbuf2krb5_data(val->GeneralString[i], error);
- if (!retval[i+1]) {
- krb5_free_principal(retval);
- return(0);
- }
- }
- retval[i+1] = 0;
- return(retval);
-#endif
-
- register krb5_principal retval;
- register int i;
- register const struct type_KRB5_PrincipalName *rv;
-
- for (i = 1, rv = val; rv->next; i++, rv = rv->next)
+ for (i = 1, rv = val->name__string; rv->next; i++, rv = rv->next)
;
- retval = (krb5_principal) malloc(sizeof(krb5_principal_data));
-
- if (!retval) {
- *error = ENOMEM;
- return(0);
- }
/* plus one for the realm */
retval->length = i;
retval->data = (krb5_data *)malloc(i * sizeof(krb5_data));
return 0;
}
+ retval->type = val->name__type;
+
if (qbuf_to_data(realm, krb5_princ_realm(retval))) {
xfree(retval->data);
xfree(retval);
return 0;
}
- for (i = 0, rv = val; rv; rv = rv->next, i++)
+ for (i = 0, rv = val->name__string; rv; rv = rv->next, i++)
if (qbuf_to_data(rv->GeneralString, krb5_princ_component(retval, i))) {
while (--i >= 0)
free(krb5_princ_component(retval, i)->data);
return retval;
}
+
+krb5_pa_data **
+element_KRB5_72krb5_pa_data(val, error)
+ struct element_KRB5_7 *val;
+ register int *error;
+{
+ register krb5_pa_data **retval;
+ register int i;
+ register struct element_KRB5_7 *rv;
+
+ for (i = 0, rv = val; rv; i++, rv = rv->next)
+ ;
+
+ /* plus one for null terminator */
+ retval = (krb5_pa_data **) xcalloc(i + 1, sizeof(*retval));
+ if (!retval) {
+ *error = ENOMEM;
+ return(0);
+ }
+ for (i = 0, rv = val; rv; rv = rv->next, i++) {
+ if (qb_pullup(rv->PA__DATA->pa__data) != OK) {
+ xfree(retval);
+ *error = ENOMEM;
+ return(0);
+ }
+ retval[i] = (krb5_pa_data *) xmalloc(sizeof(*retval[i]));
+ if (!retval[i]) {
+ krb5_free_pa_data(retval);
+ *error = ENOMEM;
+ return(0);
+ }
+ retval[i]->contents = (unsigned char *)xmalloc(rv->PA__DATA->pa__data->qb_forw->qb_len);
+ if (!retval[i]->contents) {
+ xfree(retval[i]);
+ retval[i] = 0;
+ krb5_free_pa_data(retval);
+ *error = ENOMEM;
+ return(0);
+ }
+ retval[i]->pa_type = rv->PA__DATA->padata__type;
+ retval[i]->length = rv->PA__DATA->pa__data->qb_forw->qb_len;
+ xbcopy(rv->PA__DATA->pa__data->qb_forw->qb_data,
+ retval[i]->contents, retval[i]->length);
+ }
+ retval[i] = 0;
+ return(retval);
+}
+
krb5_kdc_req *
KRB5_KDC__REQ2krb5_kdc_req(val, error)
const register struct type_KRB5_KDC__REQ *val;
retval->msg_type = val->msg__type;
if (val->padata) {
- retval->padata = KRB5_PA__DATA2krb5_pa_data(val->padata, error);
+ retval->padata = element_KRB5_72krb5_pa_data(val->padata, error);
if (!retval->padata) {
krb5_free_kdc_req(retval);
return(0);