summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_set.c')
-rw-r--r--src/lib/libcrypto/asn1/a_set.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c
index 958558c204..e24061c545 100644
--- a/src/lib/libcrypto/asn1/a_set.c
+++ b/src/lib/libcrypto/asn1/a_set.c
@@ -85,8 +85,8 @@ static int SetBlobCmp(const void *elem1, const void *elem2 )
85 } 85 }
86 86
87/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ 87/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */
88int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, 88int i2d_ASN1_SET(STACK *a, unsigned char **pp, int (*func)(), int ex_tag,
89 int ex_class, int is_set) 89 int ex_class, int is_set)
90 { 90 {
91 int ret=0,r; 91 int ret=0,r;
92 int i; 92 int i;
@@ -97,7 +97,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
97 97
98 if (a == NULL) return(0); 98 if (a == NULL) return(0);
99 for (i=sk_num(a)-1; i>=0; i--) 99 for (i=sk_num(a)-1; i>=0; i--)
100 ret+=i2d(sk_value(a,i),NULL); 100 ret+=func(sk_value(a,i),NULL);
101 r=ASN1_object_size(1,ret,ex_tag); 101 r=ASN1_object_size(1,ret,ex_tag);
102 if (pp == NULL) return(r); 102 if (pp == NULL) return(r);
103 103
@@ -111,7 +111,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
111 if(!is_set || (sk_num(a) < 2)) 111 if(!is_set || (sk_num(a) < 2))
112 { 112 {
113 for (i=0; i<sk_num(a); i++) 113 for (i=0; i<sk_num(a); i++)
114 i2d(sk_value(a,i),&p); 114 func(sk_value(a,i),&p);
115 115
116 *pp=p; 116 *pp=p;
117 return(r); 117 return(r);
@@ -129,7 +129,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
129 for (i=0; i<sk_num(a); i++) 129 for (i=0; i<sk_num(a); i++)
130 { 130 {
131 rgSetBlob[i].pbData = p; /* catch each set encode blob */ 131 rgSetBlob[i].pbData = p; /* catch each set encode blob */
132 i2d(sk_value(a,i),&p); 132 func(sk_value(a,i),&p);
133 rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this 133 rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this
134SetBlob 134SetBlob
135*/ 135*/
@@ -162,11 +162,10 @@ SetBlob
162 return(r); 162 return(r);
163 } 163 }
164 164
165STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, 165STACK *d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
166 d2i_of_void *d2i, void (*free_func)(void *), int ex_tag, 166 char *(*func)(), void (*free_func)(void *), int ex_tag, int ex_class)
167 int ex_class)
168 { 167 {
169 ASN1_const_CTX c; 168 ASN1_CTX c;
170 STACK *ret=NULL; 169 STACK *ret=NULL;
171 170
172 if ((a == NULL) || ((*a) == NULL)) 171 if ((a == NULL) || ((*a) == NULL))
@@ -211,9 +210,7 @@ STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
211 char *s; 210 char *s;
212 211
213 if (M_ASN1_D2I_end_sequence()) break; 212 if (M_ASN1_D2I_end_sequence()) break;
214 /* XXX: This was called with 4 arguments, incorrectly, it seems 213 if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL)
215 if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL) */
216 if ((s=d2i(NULL,&c.p,c.slen)) == NULL)
217 { 214 {
218 ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT); 215 ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT);
219 asn1_add_error(*pp,(int)(c.q- *pp)); 216 asn1_add_error(*pp,(int)(c.q- *pp));