diff options
| author | jsing <> | 2022-05-12 20:06:46 +0000 |
|---|---|---|
| committer | jsing <> | 2022-05-12 20:06:46 +0000 |
| commit | abd206ca1723c68b18c82cbf0f3d612db7a96b9c (patch) | |
| tree | d8e70922bbc96c47c85a56f1fdfdac570e6e7ecf /src/lib/libc | |
| parent | 3f905b4d065af2673dad6508cc74908e6b71d4c5 (diff) | |
| download | openbsd-abd206ca1723c68b18c82cbf0f3d612db7a96b9c.tar.gz openbsd-abd206ca1723c68b18c82cbf0f3d612db7a96b9c.tar.bz2 openbsd-abd206ca1723c68b18c82cbf0f3d612db7a96b9c.zip | |
Call the ASN1_OP_D2I_PRE callback after ASN1_item_ex_new().
In asn1_item_ex_d2i_choice(), only call the ASN1_OP_D2I_PRE callback after
allocation has occurred via ASN1_item_ex_new(). This matches the sequence
handling code and the documentation.
Discussed with tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index db4424b6be..48ac38a883 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.66 2022/05/12 19:52:31 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.67 2022/05/12 20:06:46 jsing 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 | */ |
| @@ -135,6 +135,9 @@ asn1_item_ex_d2i_choice(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
| 135 | ASN1_VALUE **pchptr; | 135 | ASN1_VALUE **pchptr; |
| 136 | int i, ret; | 136 | int i, ret; |
| 137 | 137 | ||
| 138 | if (aux != NULL) | ||
| 139 | asn1_cb = aux->asn1_cb; | ||
| 140 | |||
| 138 | if (it->itype != ASN1_ITYPE_CHOICE) | 141 | if (it->itype != ASN1_ITYPE_CHOICE) |
| 139 | goto err; | 142 | goto err; |
| 140 | 143 | ||
| @@ -152,21 +155,16 @@ asn1_item_ex_d2i_choice(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, | |||
| 152 | *pval = NULL; | 155 | *pval = NULL; |
| 153 | } | 156 | } |
| 154 | 157 | ||
| 155 | if (aux != NULL) | 158 | if (!ASN1_item_ex_new(&achoice, it)) { |
| 156 | asn1_cb = aux->asn1_cb; | 159 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
| 160 | goto err; | ||
| 161 | } | ||
| 157 | 162 | ||
| 158 | if (asn1_cb != NULL && !asn1_cb(ASN1_OP_D2I_PRE, &achoice, it, NULL)) { | 163 | if (asn1_cb != NULL && !asn1_cb(ASN1_OP_D2I_PRE, &achoice, it, NULL)) { |
| 159 | ASN1error(ASN1_R_AUX_ERROR); | 164 | ASN1error(ASN1_R_AUX_ERROR); |
| 160 | goto err; | 165 | goto err; |
| 161 | } | 166 | } |
| 162 | 167 | ||
| 163 | if (achoice == NULL) { | ||
| 164 | if (!ASN1_item_ex_new(&achoice, it)) { | ||
| 165 | ASN1error(ERR_R_NESTED_ASN1_ERROR); | ||
| 166 | goto err; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | /* Try each possible CHOICE in turn. */ | 168 | /* Try each possible CHOICE in turn. */ |
| 171 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { | 169 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { |
| 172 | pchptr = asn1_get_field_ptr(&achoice, tt); | 170 | pchptr = asn1_get_field_ptr(&achoice, tt); |
