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