summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/tasn_dec.c
diff options
context:
space:
mode:
authorjsing <>2019-04-01 15:48:04 +0000
committerjsing <>2019-04-01 15:48:04 +0000
commitc668655bd37c10676da50f3d90a2cb88438f14c1 (patch)
treed9cf1a8ad7b62400a812c7d2f90b7402b1f5fc83 /src/lib/libcrypto/asn1/tasn_dec.c
parente813599f2392d1fd8276b9ca150e48dedce013f8 (diff)
downloadopenbsd-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_dec.c')
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 3a27b82288..70dc355ca1 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.36 2018/09/17 18:18:01 tb Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.37 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 */
@@ -793,14 +793,17 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype,
793 ASN1_VALUE **opval = NULL; 793 ASN1_VALUE **opval = NULL;
794 ASN1_STRING *stmp; 794 ASN1_STRING *stmp;
795 ASN1_TYPE *typ = NULL; 795 ASN1_TYPE *typ = NULL;
796 int ret = 0;
797 const ASN1_PRIMITIVE_FUNCS *pf;
798 ASN1_INTEGER **tint; 796 ASN1_INTEGER **tint;
797 int ret = 0;
799 798
800 pf = it->funcs; 799 if (it->funcs != NULL) {
800 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
801 801
802 if (pf && pf->prim_c2i) 802 if (pf->prim_c2i == NULL)
803 return 0;
803 return pf->prim_c2i(pval, cont, len, utype, free_cont, it); 804 return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
805 }
806
804 /* If ANY type clear type and set pointer to internal value */ 807 /* If ANY type clear type and set pointer to internal value */
805 if (it->utype == V_ASN1_ANY) { 808 if (it->utype == V_ASN1_ANY) {
806 if (!*pval) { 809 if (!*pval) {