diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/x_name.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/x_name.c | 19 | 
1 files changed, 11 insertions, 8 deletions
| diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c index caece0f158..31f3377b64 100644 --- a/src/lib/libcrypto/asn1/x_name.c +++ b/src/lib/libcrypto/asn1/x_name.c | |||
| @@ -160,21 +160,22 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, unsigned char **in, long len, cons | |||
| 160 | int tag, int aclass, char opt, ASN1_TLC *ctx) | 160 | int tag, int aclass, char opt, ASN1_TLC *ctx) | 
| 161 | { | 161 | { | 
| 162 | unsigned char *p = *in, *q; | 162 | unsigned char *p = *in, *q; | 
| 163 | STACK *intname = NULL; | 163 | STACK *intname = NULL, **intname_pp = &intname; | 
| 164 | int i, j, ret; | 164 | int i, j, ret; | 
| 165 | X509_NAME *nm = NULL; | 165 | X509_NAME *nm = NULL, **nm_pp = &nm; | 
| 166 | STACK_OF(X509_NAME_ENTRY) *entries; | 166 | STACK_OF(X509_NAME_ENTRY) *entries; | 
| 167 | X509_NAME_ENTRY *entry; | 167 | X509_NAME_ENTRY *entry; | 
| 168 | q = p; | 168 | q = p; | 
| 169 | 169 | ||
| 170 | /* Get internal representation of Name */ | 170 | /* Get internal representation of Name */ | 
| 171 | ret = ASN1_item_ex_d2i((ASN1_VALUE **)&intname, &p, len, ASN1_ITEM_rptr(X509_NAME_INTERNAL), | 171 | ret = ASN1_item_ex_d2i((ASN1_VALUE **)intname_pp, | 
| 172 | tag, aclass, opt, ctx); | 172 | &p, len, ASN1_ITEM_rptr(X509_NAME_INTERNAL), | 
| 173 | tag, aclass, opt, ctx); | ||
| 173 | 174 | ||
| 174 | if(ret <= 0) return ret; | 175 | if(ret <= 0) return ret; | 
| 175 | 176 | ||
| 176 | if(*val) x509_name_ex_free(val, NULL); | 177 | if(*val) x509_name_ex_free(val, NULL); | 
| 177 | if(!x509_name_ex_new((ASN1_VALUE **)&nm, NULL)) goto err; | 178 | if(!x509_name_ex_new((ASN1_VALUE **)nm_pp, NULL)) goto err; | 
| 178 | /* We've decoded it: now cache encoding */ | 179 | /* We've decoded it: now cache encoding */ | 
| 179 | if(!BUF_MEM_grow(nm->bytes, p - q)) goto err; | 180 | if(!BUF_MEM_grow(nm->bytes, p - q)) goto err; | 
| 180 | memcpy(nm->bytes->data, q, p - q); | 181 | memcpy(nm->bytes->data, q, p - q); | 
| @@ -218,7 +219,7 @@ static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_IT | |||
| 218 | 219 | ||
| 219 | static int x509_name_encode(X509_NAME *a) | 220 | static int x509_name_encode(X509_NAME *a) | 
| 220 | { | 221 | { | 
| 221 | STACK *intname = NULL; | 222 | STACK *intname = NULL, **intname_pp = &intname; | 
| 222 | int len; | 223 | int len; | 
| 223 | unsigned char *p; | 224 | unsigned char *p; | 
| 224 | STACK_OF(X509_NAME_ENTRY) *entries = NULL; | 225 | STACK_OF(X509_NAME_ENTRY) *entries = NULL; | 
| @@ -236,10 +237,12 @@ static int x509_name_encode(X509_NAME *a) | |||
| 236 | } | 237 | } | 
| 237 | if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr; | 238 | if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr; | 
| 238 | } | 239 | } | 
| 239 | len = ASN1_item_ex_i2d((ASN1_VALUE **)&intname, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); | 240 | len = ASN1_item_ex_i2d((ASN1_VALUE **)intname_pp, NULL, | 
| 241 | ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); | ||
| 240 | if (!BUF_MEM_grow(a->bytes,len)) goto memerr; | 242 | if (!BUF_MEM_grow(a->bytes,len)) goto memerr; | 
| 241 | p=(unsigned char *)a->bytes->data; | 243 | p=(unsigned char *)a->bytes->data; | 
| 242 | ASN1_item_ex_i2d((ASN1_VALUE **)&intname, &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); | 244 | ASN1_item_ex_i2d((ASN1_VALUE **)intname_pp, | 
| 245 | &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); | ||
| 243 | sk_pop_free(intname, sk_internal_free); | 246 | sk_pop_free(intname, sk_internal_free); | 
| 244 | a->modified = 0; | 247 | a->modified = 0; | 
| 245 | return len; | 248 | return len; | 
