summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/tasn_fre.c
diff options
context:
space:
mode:
authorjsing <>2019-04-01 15:48:04 +0000
committerjsing <>2019-04-01 15:48:04 +0000
commita75b22a2cc094f47fbed5f4c583901562193c920 (patch)
treed9cf1a8ad7b62400a812c7d2f90b7402b1f5fc83 /src/lib/libcrypto/asn1/tasn_fre.c
parentfa03268a2594c33652da3b07feca76588192a446 (diff)
downloadopenbsd-a75b22a2cc094f47fbed5f4c583901562193c920.tar.gz
openbsd-a75b22a2cc094f47fbed5f4c583901562193c920.tar.bz2
openbsd-a75b22a2cc094f47fbed5f4c583901562193c920.zip
Require all ASN1_PRIMITIVE_FUNCS functions to be provided.
If an ASN.1 item provides its own ASN1_PRIMITIVE_FUNCS functions, require all functions to be provided (currently excluding prim_clear). This avoids situations such as having a custom allocator that returns a specific struct but then is then printed using the default primative print functions, which interpret the memory as a different struct. Found by oss-fuzz, fixes issue #13799. ok beck@, tb@
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_fre.c')
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index c05310ec28..b621af3b37 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_fre.c,v 1.16 2018/04/06 12:16:06 bluhm Exp $ */ 1/* $OpenBSD: tasn_fre.c,v 1.17 2019/04/01 15:48:04 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 */
@@ -193,14 +193,14 @@ void
193ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) 193ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
194{ 194{
195 int utype; 195 int utype;
196 if (it) { 196
197 const ASN1_PRIMITIVE_FUNCS *pf; 197 if (it != NULL && it->funcs != NULL) {
198 pf = it->funcs; 198 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
199 if (pf && pf->prim_free) { 199
200 pf->prim_free(pval, it); 200 pf->prim_free(pval, it);
201 return; 201 return;
202 }
203 } 202 }
203
204 /* Special case: if 'it' is NULL free contents of ASN1_TYPE */ 204 /* Special case: if 'it' is NULL free contents of ASN1_TYPE */
205 if (!it) { 205 if (!it) {
206 ASN1_TYPE *typ = (ASN1_TYPE *)*pval; 206 ASN1_TYPE *typ = (ASN1_TYPE *)*pval;