diff options
| author | tb <> | 2023-03-15 06:30:21 +0000 | 
|---|---|---|
| committer | tb <> | 2023-03-15 06:30:21 +0000 | 
| commit | 0d6436e7ce4a2c17cfea40b64872c615b4ff93da (patch) | |
| tree | be2eeb8f1d2f6fd3e77f25e6d1fbb5a15aa82fb2 /src | |
| parent | fe08170ae5385adab5596b5e0d20cd32170b58ba (diff) | |
| download | openbsd-0d6436e7ce4a2c17cfea40b64872c615b4ff93da.tar.gz openbsd-0d6436e7ce4a2c17cfea40b64872c615b4ff93da.tar.bz2 openbsd-0d6436e7ce4a2c17cfea40b64872c615b4ff93da.zip  | |
Add comments that explain why things are done in this strange order.
There's some method to this madness.
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/bio_ndef.c | 16 | 
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c index 606b08a286..b1fcc4dd15 100644 --- a/src/lib/libcrypto/asn1/bio_ndef.c +++ b/src/lib/libcrypto/asn1/bio_ndef.c  | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bio_ndef.c,v 1.19 2023/03/15 06:28:55 tb Exp $ */ | 1 | /* $OpenBSD: bio_ndef.c,v 1.20 2023/03/15 06:30:21 tb 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. | 3 | * project. | 
| 4 | */ | 4 | */ | 
| @@ -117,11 +117,20 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) | |||
| 117 | goto err; | 117 | goto err; | 
| 118 | pop_bio = asn_bio; | 118 | pop_bio = asn_bio; | 
| 119 | 119 | ||
| 120 | /* | ||
| 121 | * Set up prefix and suffix handlers first. This ensures that ndef_aux | ||
| 122 | * is freed as part of asn_bio once it is the asn_bio's ex_arg. | ||
| 123 | */ | ||
| 120 | if (BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free) <= 0) | 124 | if (BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free) <= 0) | 
| 121 | goto err; | 125 | goto err; | 
| 122 | if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0) | 126 | if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0) | 
| 123 | goto err; | 127 | goto err; | 
| 124 | 128 | ||
| 129 | /* | ||
| 130 | * Allocate early to avoid the tricky cleanup after the asn1_cb(). | ||
| 131 | * Ownership of ndef_aux is transferred to asn_bio in BIO_ctrl(). | ||
| 132 | * Keep a reference to populate it after callback success. | ||
| 133 | */ | ||
| 125 | if ((ndef_aux = calloc(1, sizeof(*ndef_aux))) == NULL) | 134 | if ((ndef_aux = calloc(1, sizeof(*ndef_aux))) == NULL) | 
| 126 | goto err; | 135 | goto err; | 
| 127 | if (BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0) { | 136 | if (BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0) { | 
| @@ -129,8 +138,9 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) | |||
| 129 | goto err; | 138 | goto err; | 
| 130 | } | 139 | } | 
| 131 | 140 | ||
| 132 | /* Now let callback prepend any digest, cipher etc BIOs | 141 | /* | 
| 133 | * ASN1 structure needs. | 142 | * The callback prepends BIOs to the chain starting at asn_bio for | 
| 143 | * digest, cipher, etc. The resulting chain starts at sarg.ndef_bio. | ||
| 134 | */ | 144 | */ | 
| 135 | 145 | ||
| 136 | sarg.out = asn_bio; | 146 | sarg.out = asn_bio; | 
