From: John Kohl Date: Tue, 12 Mar 1991 16:47:46 +0000 (+0000) Subject: pepsy changes (rearranged structures) X-Git-Tag: krb5-1.0-alpha4~92 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6d3d0301b88767c3b9df1b751a0360c578eed0e6;p=krb5.git pepsy changes (rearranged structures) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1880 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/adat2kadat.c b/src/lib/krb5/asn.1/adat2kadat.c index 69bcad0e2..84fdf28de 100644 --- a/src/lib/krb5/asn.1/adat2kadat.c +++ b/src/lib/krb5/asn.1/adat2kadat.c @@ -32,6 +32,10 @@ KRB5_AuthorizationData2krb5_authdata(val, error) const struct type_KRB5_AuthorizationData *val; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register krb5_authdata **retval; register int i; @@ -56,6 +60,7 @@ register int *error; retval[i]->contents = (unsigned char *)xmalloc(val->element_KRB5_2[i]->ad__data->qb_forw->qb_len); if (!retval[i]->contents) { xfree(retval[i]); + retval[i] = 0; krb5_free_authdata(retval); goto nomem; } @@ -66,4 +71,44 @@ register int *error; } retval[i] = 0; return(retval); +#endif + + register krb5_authdata **retval; + register int i; + register struct type_KRB5_AuthorizationData *rv; + + for (i = 0, rv = val; rv; i++, rv = rv->next) + ; + + /* plus one for null terminator */ + retval = (krb5_authdata **) xcalloc(i + 1, sizeof(*retval)); + if (!retval) { + nomem: + *error = ENOMEM; + return(0); + } + for (i = 0, rv = val; rv->next; rv = rv->next, i++) { + if (qb_pullup(rv->element_KRB5_2->ad__data) != OK) { + xfree(retval); + goto nomem; + } + retval[i] = (krb5_authdata *) xmalloc(sizeof(*retval[i])); + if (!retval[i]) { + krb5_free_authdata(retval); + goto nomem; + } + retval[i]->contents = (unsigned char *)xmalloc(rv->element_KRB5_2->ad__data->qb_forw->qb_len); + if (!retval[i]->contents) { + xfree(retval[i]); + retval[i] = 0; + krb5_free_authdata(retval); + goto nomem; + } + retval[i]->ad_type = rv->element_KRB5_2->ad__type; + retval[i]->length = rv->element_KRB5_2->ad__data->qb_forw->qb_len; + xbcopy(rv->element_KRB5_2->ad__data->qb_forw->qb_data, + retval[i]->contents, retval[i]->length); + } + retval[i] = 0; + return(retval); } diff --git a/src/lib/krb5/asn.1/addr2kaddr.c b/src/lib/krb5/asn.1/addr2kaddr.c index 8bc295bed..32a0989e2 100644 --- a/src/lib/krb5/asn.1/addr2kaddr.c +++ b/src/lib/krb5/asn.1/addr2kaddr.c @@ -34,6 +34,10 @@ KRB5_HostAddresses2krb5_address(val, error) const struct type_KRB5_HostAddresses *val; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register krb5_address **retval; register int i; @@ -57,6 +61,7 @@ register int *error; retval[i]->contents = (unsigned char *)xmalloc(val->element_KRB5_0[i]->address->qb_forw->qb_len); if (!retval[i]->contents) { xfree(retval[i]); + retval[i] = 0; krb5_free_address(retval); goto nomem; } @@ -67,5 +72,45 @@ register int *error; } retval[i] = 0; return(retval); +#endif + + register krb5_address **retval; + register int i; + register struct type_KRB5_HostAddresses *rv; + + for (i = 0, rv = val; rv; i++, rv = rv->next) + ; + + /* plus one for null terminator */ + retval = (krb5_address **) xcalloc(i + 1, sizeof(*retval)); + if (!retval) { + nomem: + *error = ENOMEM; + return(0); + } + for (i = 0, rv = val; rv; rv = rv->next, i++) { + if (qb_pullup(rv->element_KRB5_0->address) != OK) { + xfree(retval); + goto nomem; + } + retval[i] = (krb5_address *) xmalloc(sizeof(*retval[i])); + if (!retval[i]) { + krb5_free_address(retval); + goto nomem; + } + retval[i]->contents = (unsigned char *)xmalloc(rv->element_KRB5_0->address->qb_forw->qb_len); + if (!retval[i]->contents) { + xfree(retval[i]); + retval[i] = 0; + krb5_free_address(retval); + goto nomem; + } + retval[i]->addrtype = rv->element_KRB5_0->addr__type; + retval[i]->length = rv->element_KRB5_0->address->qb_forw->qb_len; + xbcopy(rv->element_KRB5_0->address->qb_forw->qb_data, + retval[i]->contents, retval[i]->length); + } + retval[i] = 0; + return(retval); } diff --git a/src/lib/krb5/asn.1/kadat2adat.c b/src/lib/krb5/asn.1/kadat2adat.c index edbbb187b..2ae06e51c 100644 --- a/src/lib/krb5/asn.1/kadat2adat.c +++ b/src/lib/krb5/asn.1/kadat2adat.c @@ -32,6 +32,10 @@ krb5_authdata2KRB5_AuthorizationData(val, error) register krb5_authdata * const *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_AuthorizationData *retval; register krb5_authdata * const *temp; register int i; @@ -68,4 +72,42 @@ register int *error; } } return(retval); +#endif + register struct type_KRB5_AuthorizationData *retval = 0, *rv1 = 0, *rv2; + register krb5_authdata * const *temp; + register int i; + + /* count elements */ + for (i = 0, temp = val; *temp; temp++,i++, rv1 = rv2) { + + rv2 = (struct type_KRB5_AuthorizationData *) xmalloc(sizeof(*rv2)); + if (!rv2) { + if (retval) + free_KRB5_AuthorizationData(retval); + *error = ENOMEM; + return(0); + } + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!retval) + retval = rv2; + + rv2->element_KRB5_2 = (struct element_KRB5_3 *) + xmalloc(sizeof(*(rv2->element_KRB5_2))); + if (!rv2->element_KRB5_2) { + errout: + if (retval) + free_KRB5_AuthorizationData(retval); + *error = ENOMEM; + return(0); + } + rv2->element_KRB5_2->ad__type = val[i]->ad_type; + rv2->element_KRB5_2->ad__data = str2qb((char *)(val[i])->contents, + (val[i])->length, 1); + if (!rv2->element_KRB5_2->ad__data) { + goto errout; + } + } + return(retval); } diff --git a/src/lib/krb5/asn.1/kaddr2addr.c b/src/lib/krb5/asn.1/kaddr2addr.c index 579638f55..2a02226b2 100644 --- a/src/lib/krb5/asn.1/kaddr2addr.c +++ b/src/lib/krb5/asn.1/kaddr2addr.c @@ -32,6 +32,10 @@ krb5_address2KRB5_HostAddresses(val, error) register krb5_address * const *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_HostAddresses *retval; register krb5_address * const *temp; register int i; @@ -67,4 +71,43 @@ register int *error; } } return(retval); +#endif + register struct type_KRB5_HostAddresses *retval = 0, *rv1 = 0, *rv2; + register krb5_address * const *temp; + register int i; + + for (i = 0, temp = val; *temp; temp++,i++, rv1 = rv2) { + + rv2 = (struct type_KRB5_HostAddresses *) xmalloc(sizeof(*rv2)); + if (!rv2) { + if (retval) + free_KRB5_HostAddresses(retval); + *error = ENOMEM; + return(0); + } + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!retval) + retval = rv2; + + rv2->element_KRB5_0 = (struct element_KRB5_1 *) + xmalloc(sizeof(*(retval->element_KRB5_0))); + if (!rv2->element_KRB5_0) { + errout: + if (retval) + free_KRB5_HostAddresses(retval); + *error = ENOMEM; + return(0); + } + rv2->element_KRB5_0->addr__type = (val[i])->addrtype; + rv2->element_KRB5_0->address = str2qb((char *)(val[i])->contents, + (val[i])->length, 1); + if (!rv2->element_KRB5_0->address) { + /* clean up */ + xfree(rv2->element_KRB5_0); + goto errout; + } + } + return(retval); }