diff options
author | Richard Levitte <levitte@openssl.org> | 2017-04-12 11:48:12 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-04-13 10:26:48 +0200 |
commit | adc0e6f349d44168ef9250c651273651b455c513 (patch) | |
tree | 921f1489bc5ece57d9bcc4c570b027982990f3c7 /crypto/asn1 | |
parent | e7bed7632c33211d5b7b03ace412bf4ffa3b98aa (diff) |
ASN.1: extend the possibilities to embed data instead of pointers
Also, when "allocating" or "deallocating" an embedded item, never call
prim_new() or prim_free(). Call prim_clear() instead.
Fixes #3191
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3200)
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/tasn_fre.c | 7 | ||||
-rw-r--r-- | crypto/asn1/tasn_new.c | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index 3c98efb363..ae91461774 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -155,7 +155,12 @@ void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) if (it) { const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; - if (pf && pf->prim_free) { + if (embed) { + if (pf && pf->prim_clear) { + pf->prim_clear(pval, it); + return; + } + } else if (pf && pf->prim_free) { pf->prim_free(pval, it); return; } diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index e9b83773f1..f695e38da0 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -266,8 +266,14 @@ static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, if (it->funcs) { const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; - if (pf->prim_new) + if (embed) { + if (pf->prim_clear) { + pf->prim_clear(pval, it); + return 1; + } + } else if (pf->prim_new) { return pf->prim_new(pval, it); + } } if (it->itype == ASN1_ITYPE_MSTRING) |