diff options
author | jsing <> | 2019-04-01 15:48:04 +0000 |
---|---|---|
committer | jsing <> | 2019-04-01 15:48:04 +0000 |
commit | a75b22a2cc094f47fbed5f4c583901562193c920 (patch) | |
tree | d9cf1a8ad7b62400a812c7d2f90b7402b1f5fc83 /src/lib/libcrypto/asn1/tasn_enc.c | |
parent | fa03268a2594c33652da3b07feca76588192a446 (diff) | |
download | openbsd-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_enc.c')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_enc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c index f3341901fe..d103c4d096 100644 --- a/src/lib/libcrypto/asn1/tasn_enc.c +++ b/src/lib/libcrypto/asn1/tasn_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tasn_enc.c,v 1.21 2016/12/30 16:04:34 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_enc.c,v 1.22 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 | */ |
@@ -541,11 +541,14 @@ asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | |||
541 | const unsigned char *cont; | 541 | const unsigned char *cont; |
542 | unsigned char c; | 542 | unsigned char c; |
543 | int len; | 543 | int len; |
544 | const ASN1_PRIMITIVE_FUNCS *pf; | ||
545 | 544 | ||
546 | pf = it->funcs; | 545 | if (it->funcs != NULL) { |
547 | if (pf && pf->prim_i2c) | 546 | const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; |
547 | |||
548 | if (pf->prim_i2c == NULL) | ||
549 | return -1; | ||
548 | return pf->prim_i2c(pval, cout, putype, it); | 550 | return pf->prim_i2c(pval, cout, putype, it); |
551 | } | ||
549 | 552 | ||
550 | /* Should type be omitted? */ | 553 | /* Should type be omitted? */ |
551 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) || | 554 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) || |