diff options
| author | jsing <> | 2019-04-01 15:48:04 +0000 |
|---|---|---|
| committer | jsing <> | 2019-04-01 15:48:04 +0000 |
| commit | c668655bd37c10676da50f3d90a2cb88438f14c1 (patch) | |
| tree | d9cf1a8ad7b62400a812c7d2f90b7402b1f5fc83 /src/lib/libcrypto/asn1/tasn_fre.c | |
| parent | e813599f2392d1fd8276b9ca150e48dedce013f8 (diff) | |
| download | openbsd-c668655bd37c10676da50f3d90a2cb88438f14c1.tar.gz openbsd-c668655bd37c10676da50f3d90a2cb88438f14c1.tar.bz2 openbsd-c668655bd37c10676da50f3d90a2cb88438f14c1.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.c | 16 |
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 | |||
| 193 | ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | 193 | ASN1_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; |
