diff options
author | inoguchi <> | 2020-03-24 10:46:38 +0000 |
---|---|---|
committer | inoguchi <> | 2020-03-24 10:46:38 +0000 |
commit | 4f15f3172c845dc44cd80a8defde231fbaa61e27 (patch) | |
tree | 8a626a625e36d6a487649c03f9dd6269df410cb4 | |
parent | ed759aa6a877b98293e7fa74ea83ad183ea1157d (diff) | |
download | openbsd-4f15f3172c845dc44cd80a8defde231fbaa61e27.tar.gz openbsd-4f15f3172c845dc44cd80a8defde231fbaa61e27.tar.bz2 openbsd-4f15f3172c845dc44cd80a8defde231fbaa61e27.zip |
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@
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_prn.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c index ab8985318e..4c676d8c04 100644 --- a/src/lib/libcrypto/asn1/tasn_prn.c +++ b/src/lib/libcrypto/asn1/tasn_prn.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tasn_prn.c,v 1.20 2019/04/07 16:35:50 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_prn.c,v 1.21 2020/03/24 10:46:38 inoguchi 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 | */ |
@@ -216,7 +216,8 @@ asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, | |||
216 | } else | 216 | } else |
217 | asn1_cb = NULL; | 217 | asn1_cb = NULL; |
218 | 218 | ||
219 | if (*fld == NULL) { | 219 | if ((it->itype != ASN1_ITYPE_PRIMITIVE || |
220 | it->utype != V_ASN1_BOOLEAN) && *fld == NULL) { | ||
220 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { | 221 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { |
221 | if (!nohdr && | 222 | if (!nohdr && |
222 | !asn1_print_fsname(out, indent, fname, sname, pctx)) | 223 | !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) | |||
454 | { | 455 | { |
455 | char *s; | 456 | char *s; |
456 | int ret = 1; | 457 | int ret = 1; |
457 | s = i2s_ASN1_INTEGER(NULL, str); | 458 | if ((s = i2s_ASN1_INTEGER(NULL, str)) == NULL) |
459 | return 0; | ||
458 | if (BIO_puts(out, s) <= 0) | 460 | if (BIO_puts(out, s) <= 0) |
459 | ret = 0; | 461 | ret = 0; |
460 | free(s); | 462 | free(s); |
@@ -512,11 +514,16 @@ asn1_primitive_print(BIO *out, ASN1_VALUE **fld, const ASN1_ITEM *it, | |||
512 | 514 | ||
513 | return pf->prim_print(out, fld, it, indent, pctx); | 515 | return pf->prim_print(out, fld, it, indent, pctx); |
514 | } | 516 | } |
515 | str = (ASN1_STRING *)*fld; | 517 | if (it->itype == ASN1_ITYPE_MSTRING) { |
516 | if (it->itype == ASN1_ITYPE_MSTRING) | 518 | str = (ASN1_STRING *)*fld; |
517 | utype = str->type & ~V_ASN1_NEG; | 519 | utype = str->type & ~V_ASN1_NEG; |
518 | else | 520 | } else { |
519 | utype = it->utype; | 521 | utype = it->utype; |
522 | if (utype == V_ASN1_BOOLEAN) | ||
523 | str = NULL; | ||
524 | else | ||
525 | str = (ASN1_STRING *)*fld; | ||
526 | } | ||
520 | if (utype == V_ASN1_ANY) { | 527 | if (utype == V_ASN1_ANY) { |
521 | ASN1_TYPE *atype = (ASN1_TYPE *)*fld; | 528 | ASN1_TYPE *atype = (ASN1_TYPE *)*fld; |
522 | utype = atype->type; | 529 | utype = atype->type; |