pepsy changes (rearranged structures)
authorJohn Kohl <jtkohl@mit.edu>
Tue, 12 Mar 1991 16:47:46 +0000 (16:47 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Tue, 12 Mar 1991 16:47:46 +0000 (16:47 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1880 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/adat2kadat.c
src/lib/krb5/asn.1/addr2kaddr.c
src/lib/krb5/asn.1/kadat2adat.c
src/lib/krb5/asn.1/kaddr2addr.c

index 69bcad0e21455f1a599efaf4813f4ed4f033584f..84fdf28deb6e29f4b893a7e3396732ed83580c99 100644 (file)
@@ -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);
 }
index 8bc295bedc719528b4c23549e8a5c25a63d0c366..32a0989e2f681320405a82e460486456e697119e 100644 (file)
@@ -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);
 }
 
index edbbb187b21328a5b92dd682fcbb02e32bb50fb5..2ae06e51c8830a079e3eade33bc91abe63199650 100644 (file)
@@ -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);
 }
index 579638f558a1fcc060673f5f3789e5300654d0d8..2a02226b2f50197d3a507c31b061a7e65cfdc04d 100644 (file)
@@ -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);
 }