diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_dec.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index 791a10a9c0..7d61a6a233 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tasn_dec.c,v 1.25 2015/02/14 15:23:57 miod Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.26 2015/03/19 14:00:22 tedu Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -238,8 +238,16 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
| 238 | if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) | 238 | if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) |
| 239 | goto auxerr; | 239 | goto auxerr; |
| 240 | 240 | ||
| 241 | /* Allocate structure */ | 241 | if (*pval) { |
| 242 | if (!*pval && !ASN1_item_ex_new(pval, it)) { | 242 | /* Free up and zero CHOICE value if initialised */ |
| 243 | i = asn1_get_choice_selector(pval, it); | ||
| 244 | if ((i >= 0) && (i < it->tcount)) { | ||
| 245 | tt = it->templates + i; | ||
| 246 | pchptr = asn1_get_field_ptr(pval, tt); | ||
| 247 | ASN1_template_free(pchptr, tt); | ||
| 248 | asn1_set_choice_selector(pval, -1, it); | ||
| 249 | } | ||
| 250 | } else if (!ASN1_item_ex_new(pval, it)) { | ||
| 243 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 251 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, |
| 244 | ERR_R_NESTED_ASN1_ERROR); | 252 | ERR_R_NESTED_ASN1_ERROR); |
| 245 | goto err; | 253 | goto err; |
| @@ -325,6 +333,19 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
| 325 | if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) | 333 | if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) |
| 326 | goto auxerr; | 334 | goto auxerr; |
| 327 | 335 | ||
| 336 | /* Free up and zero any ADB found */ | ||
| 337 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { | ||
| 338 | if (tt->flags & ASN1_TFLG_ADB_MASK) { | ||
| 339 | const ASN1_TEMPLATE *seqtt; | ||
| 340 | ASN1_VALUE **pseqval; | ||
| 341 | seqtt = asn1_do_adb(pval, tt, 1); | ||
| 342 | if (!seqtt) | ||
| 343 | goto err; | ||
| 344 | pseqval = asn1_get_field_ptr(pval, seqtt); | ||
| 345 | ASN1_template_free(pseqval, seqtt); | ||
| 346 | } | ||
| 347 | } | ||
| 348 | |||
| 328 | /* Get each field entry */ | 349 | /* Get each field entry */ |
| 329 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { | 350 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { |
| 330 | const ASN1_TEMPLATE *seqtt; | 351 | const ASN1_TEMPLATE *seqtt; |
