summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_d2i_fp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_d2i_fp.c')
-rw-r--r--src/lib/libcrypto/asn1/a_d2i_fp.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/a_d2i_fp.c b/src/lib/libcrypto/asn1/a_d2i_fp.c
index ece40bc4c0..b67b75e7c2 100644
--- a/src/lib/libcrypto/asn1/a_d2i_fp.c
+++ b/src/lib/libcrypto/asn1/a_d2i_fp.c
@@ -66,10 +66,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
66#ifndef NO_OLD_ASN1 66#ifndef NO_OLD_ASN1
67#ifndef OPENSSL_NO_FP_API 67#ifndef OPENSSL_NO_FP_API
68 68
69void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x) 69char *ASN1_d2i_fp(char *(*xnew)(), char *(*d2i)(), FILE *in,
70 unsigned char **x)
70 { 71 {
71 BIO *b; 72 BIO *b;
72 void *ret; 73 char *ret;
73 74
74 if ((b=BIO_new(BIO_s_file())) == NULL) 75 if ((b=BIO_new(BIO_s_file())) == NULL)
75 { 76 {
@@ -83,11 +84,12 @@ void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x)
83 } 84 }
84#endif 85#endif
85 86
86void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x) 87char *ASN1_d2i_bio(char *(*xnew)(), char *(*d2i)(), BIO *in,
88 unsigned char **x)
87 { 89 {
88 BUF_MEM *b = NULL; 90 BUF_MEM *b = NULL;
89 const unsigned char *p; 91 unsigned char *p;
90 void *ret=NULL; 92 char *ret=NULL;
91 int len; 93 int len;
92 94
93 len = asn1_d2i_read_bio(in, &b); 95 len = asn1_d2i_read_bio(in, &b);
@@ -105,14 +107,14 @@ err:
105void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) 107void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
106 { 108 {
107 BUF_MEM *b = NULL; 109 BUF_MEM *b = NULL;
108 const unsigned char *p; 110 unsigned char *p;
109 void *ret=NULL; 111 void *ret=NULL;
110 int len; 112 int len;
111 113
112 len = asn1_d2i_read_bio(in, &b); 114 len = asn1_d2i_read_bio(in, &b);
113 if(len < 0) goto err; 115 if(len < 0) goto err;
114 116
115 p=(const unsigned char *)b->data; 117 p=(unsigned char *)b->data;
116 ret=ASN1_item_d2i(x,&p,len, it); 118 ret=ASN1_item_d2i(x,&p,len, it);
117err: 119err:
118 if (b != NULL) BUF_MEM_free(b); 120 if (b != NULL) BUF_MEM_free(b);
@@ -127,7 +129,7 @@ void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
127 129
128 if ((b=BIO_new(BIO_s_file())) == NULL) 130 if ((b=BIO_new(BIO_s_file())) == NULL)
129 { 131 {
130 ASN1err(ASN1_F_ASN1_ITEM_D2I_FP,ERR_R_BUF_LIB); 132 ASN1err(ASN1_F_ASN1_D2I_FP,ERR_R_BUF_LIB);
131 return(NULL); 133 return(NULL);
132 } 134 }
133 BIO_set_fp(b,in,BIO_NOCLOSE); 135 BIO_set_fp(b,in,BIO_NOCLOSE);
@@ -144,7 +146,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
144 unsigned char *p; 146 unsigned char *p;
145 int i; 147 int i;
146 int ret=-1; 148 int ret=-1;
147 ASN1_const_CTX c; 149 ASN1_CTX c;
148 int want=HEADER_SIZE; 150 int want=HEADER_SIZE;
149 int eos=0; 151 int eos=0;
150#if defined(__GNUC__) && defined(__ia64) 152#if defined(__GNUC__) && defined(__ia64)
@@ -158,7 +160,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
158 b=BUF_MEM_new(); 160 b=BUF_MEM_new();
159 if (b == NULL) 161 if (b == NULL)
160 { 162 {
161 ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
162 return -1; 164 return -1;
163 } 165 }
164 166
@@ -171,13 +173,13 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
171 173
172 if (!BUF_MEM_grow_clean(b,len+want)) 174 if (!BUF_MEM_grow_clean(b,len+want))
173 { 175 {
174 ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); 176 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
175 goto err; 177 goto err;
176 } 178 }
177 i=BIO_read(in,&(b->data[len]),want); 179 i=BIO_read(in,&(b->data[len]),want);
178 if ((i < 0) && ((len-off) == 0)) 180 if ((i < 0) && ((len-off) == 0))
179 { 181 {
180 ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_NOT_ENOUGH_DATA); 182 ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA);
181 goto err; 183 goto err;
182 } 184 }
183 if (i > 0) 185 if (i > 0)
@@ -197,7 +199,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
197 if (e != ASN1_R_TOO_LONG) 199 if (e != ASN1_R_TOO_LONG)
198 goto err; 200 goto err;
199 else 201 else
200 ERR_clear_error(); /* clear error */ 202 ERR_get_error(); /* clear error */
201 } 203 }
202 i=c.p-p;/* header length */ 204 i=c.p-p;/* header length */
203 off+=i; /* end of data */ 205 off+=i; /* end of data */
@@ -226,7 +228,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
226 want-=(len-off); 228 want-=(len-off);
227 if (!BUF_MEM_grow_clean(b,len+want)) 229 if (!BUF_MEM_grow_clean(b,len+want))
228 { 230 {
229 ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); 231 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
230 goto err; 232 goto err;
231 } 233 }
232 while (want > 0) 234 while (want > 0)
@@ -234,7 +236,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
234 i=BIO_read(in,&(b->data[len]),want); 236 i=BIO_read(in,&(b->data[len]),want);
235 if (i <= 0) 237 if (i <= 0)
236 { 238 {
237 ASN1err(ASN1_F_ASN1_D2I_READ_BIO, 239 ASN1err(ASN1_F_ASN1_D2I_BIO,
238 ASN1_R_NOT_ENOUGH_DATA); 240 ASN1_R_NOT_ENOUGH_DATA);
239 goto err; 241 goto err;
240 } 242 }