diff options
author | Kinichiro Inoguchi <inoguchi@cvs.openbsd.org> | 2020-03-24 10:46:39 +0000 |
---|---|---|
committer | Kinichiro Inoguchi <inoguchi@cvs.openbsd.org> | 2020-03-24 10:46:39 +0000 |
commit | 307521d467878e8a46da4c0304b6748a0453ddcf (patch) | |
tree | 3d37a6427a23971a6de54893c04ca797a272ae33 /lib/libcrypto/asn1 | |
parent | bb9527cdafa789a30dd81f04e7d27f62c67a7379 (diff) |
Fix ASN1 print functions
Check and print out boolean type properly.
Based on OpenSSL commit ad72d9fdf7709ddb97a58d7d45d755e6e0504b96.
Reduced unneeded parentheses from if condition.
Check return value from i2s_ASN1_INTEGER.
Based on OpenSSL commit 5e3553c2de9a365479324b8ba8b998f0cce3e527.
Added if condition expression and return 0 if NULL is returned.
ok tb@
Diffstat (limited to 'lib/libcrypto/asn1')
-rw-r--r-- | lib/libcrypto/asn1/tasn_prn.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/libcrypto/asn1/tasn_prn.c b/lib/libcrypto/asn1/tasn_prn.c index ab8985318ef..4c676d8c04f 100644 --- a/lib/libcrypto/asn1/tasn_prn.c +++ b/lib/libcrypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.20 2019/04/07 16:35:50 jsing Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.21 2020/03/24 10:46:38 inoguchi Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -216,7 +216,8 @@ asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, } else asn1_cb = NULL; - if (*fld == NULL) { + if ((it->itype != ASN1_ITYPE_PRIMITIVE || + it->utype != V_ASN1_BOOLEAN) && *fld == NULL) { if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) @@ -454,7 +455,8 @@ asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str, const ASN1_PCTX *pctx) { char *s; int ret = 1; - s = i2s_ASN1_INTEGER(NULL, str); + if ((s = i2s_ASN1_INTEGER(NULL, str)) == NULL) + return 0; if (BIO_puts(out, s) <= 0) ret = 0; free(s); @@ -512,11 +514,16 @@ asn1_primitive_print(BIO *out, ASN1_VALUE **fld, const ASN1_ITEM *it, return pf->prim_print(out, fld, it, indent, pctx); } - str = (ASN1_STRING *)*fld; - if (it->itype == ASN1_ITYPE_MSTRING) + if (it->itype == ASN1_ITYPE_MSTRING) { + str = (ASN1_STRING *)*fld; utype = str->type & ~V_ASN1_NEG; - else + } else { utype = it->utype; + if (utype == V_ASN1_BOOLEAN) + str = NULL; + else + str = (ASN1_STRING *)*fld; + } if (utype == V_ASN1_ANY) { ASN1_TYPE *atype = (ASN1_TYPE *)*fld; utype = atype->type; |