summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_bytes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_bytes.c')
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index e452e03b88..8cde695804 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -71,7 +71,7 @@ B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, 71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
72 }; 72 };
73 73
74static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c); 74static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
75/* type is a 'bitmap' of acceptable string types. 75/* type is a 'bitmap' of acceptable string types.
76 */ 76 */
77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp, 77ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
@@ -124,7 +124,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
124 else 124 else
125 s=NULL; 125 s=NULL;
126 126
127 if (ret->data != NULL) Free((char *)ret->data); 127 if (ret->data != NULL) Free(ret->data);
128 ret->length=(int)len; 128 ret->length=(int)len;
129 ret->data=s; 129 ret->data=s;
130 ret->type=tag; 130 ret->type=tag;
@@ -205,7 +205,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
205 c.tag=Ptag; 205 c.tag=Ptag;
206 c.xclass=Pclass; 206 c.xclass=Pclass;
207 c.max=(length == 0)?0:(p+length); 207 c.max=(length == 0)?0:(p+length);
208 if (!asn1_collate_primative(ret,&c)) 208 if (!asn1_collate_primitive(ret,&c))
209 goto err; 209 goto err;
210 else 210 else
211 { 211 {
@@ -218,8 +218,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
218 { 218 {
219 if ((ret->length < len) || (ret->data == NULL)) 219 if ((ret->length < len) || (ret->data == NULL))
220 { 220 {
221 if (ret->data != NULL) Free((char *)ret->data); 221 if (ret->data != NULL) Free(ret->data);
222 s=(unsigned char *)Malloc((int)len); 222 s=(unsigned char *)Malloc((int)len + 1);
223 if (s == NULL) 223 if (s == NULL)
224 { 224 {
225 i=ERR_R_MALLOC_FAILURE; 225 i=ERR_R_MALLOC_FAILURE;
@@ -229,12 +229,13 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
229 else 229 else
230 s=ret->data; 230 s=ret->data;
231 memcpy(s,p,(int)len); 231 memcpy(s,p,(int)len);
232 s[len] = '\0';
232 p+=len; 233 p+=len;
233 } 234 }
234 else 235 else
235 { 236 {
236 s=NULL; 237 s=NULL;
237 if (ret->data != NULL) Free((char *)ret->data); 238 if (ret->data != NULL) Free(ret->data);
238 } 239 }
239 240
240 ret->length=(int)len; 241 ret->length=(int)len;
@@ -253,11 +254,11 @@ err:
253 } 254 }
254 255
255 256
256/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapes 257/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse
257 * them into the one struture that is then returned */ 258 * them into the one structure that is then returned */
258/* There have been a few bug fixes for this function from 259/* There have been a few bug fixes for this function from
259 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */ 260 * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
260static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c) 261static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
261 { 262 {
262 ASN1_STRING *os=NULL; 263 ASN1_STRING *os=NULL;
263 BUF_MEM b; 264 BUF_MEM b;