From 03c6c313948247939e6d31a9c40209243eb569f7 Mon Sep 17 00:00:00 2001 From: miod <> Date: Sat, 14 Feb 2015 15:15:27 +0000 Subject: Possible NULL pointer dereferences. Coverity CID 21719, 21732. ok doug@ jsing@ --- src/lib/libcrypto/asn1/tasn_new.c | 5 +++-- src/lib/libcrypto/asn1/tasn_prn.c | 5 ++++- src/lib/libssl/src/crypto/asn1/tasn_new.c | 5 +++-- src/lib/libssl/src/crypto/asn1/tasn_prn.c | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c index cbc6bfc1d5..86b2b3facd 100644 --- a/src/lib/libcrypto/asn1/tasn_new.c +++ b/src/lib/libcrypto/asn1/tasn_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_new.c,v 1.12 2015/02/14 13:32:46 jsing Exp $ */ +/* $OpenBSD: tasn_new.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -351,7 +351,8 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) default: str = ASN1_STRING_type_new(utype); - if (it->itype == ASN1_ITYPE_MSTRING && str) + if (it != NULL && it->itype == ASN1_ITYPE_MSTRING && + str != NULL) str->flags |= ASN1_STRING_FLAG_MSTRING; *pval = (ASN1_VALUE *)str; break; diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c index 844960fc77..c9fde96789 100644 --- a/src/lib/libcrypto/asn1/tasn_prn.c +++ b/src/lib/libcrypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.12 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -301,7 +301,10 @@ asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, /* Print each field entry */ for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; + seqtt = asn1_do_adb(fld, tt, 1); + if (seqtt == NULL) + return 0; tmpfld = asn1_get_field_ptr(fld, seqtt); if (!asn1_template_print_ctx(out, tmpfld, indent + 2, seqtt, pctx)) diff --git a/src/lib/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c index cbc6bfc1d5..86b2b3facd 100644 --- a/src/lib/libssl/src/crypto/asn1/tasn_new.c +++ b/src/lib/libssl/src/crypto/asn1/tasn_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_new.c,v 1.12 2015/02/14 13:32:46 jsing Exp $ */ +/* $OpenBSD: tasn_new.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -351,7 +351,8 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) default: str = ASN1_STRING_type_new(utype); - if (it->itype == ASN1_ITYPE_MSTRING && str) + if (it != NULL && it->itype == ASN1_ITYPE_MSTRING && + str != NULL) str->flags |= ASN1_STRING_FLAG_MSTRING; *pval = (ASN1_VALUE *)str; break; diff --git a/src/lib/libssl/src/crypto/asn1/tasn_prn.c b/src/lib/libssl/src/crypto/asn1/tasn_prn.c index 844960fc77..c9fde96789 100644 --- a/src/lib/libssl/src/crypto/asn1/tasn_prn.c +++ b/src/lib/libssl/src/crypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.12 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -301,7 +301,10 @@ asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, /* Print each field entry */ for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; + seqtt = asn1_do_adb(fld, tt, 1); + if (seqtt == NULL) + return 0; tmpfld = asn1_get_field_ptr(fld, seqtt); if (!asn1_template_print_ctx(out, tmpfld, indent + 2, seqtt, pctx)) -- cgit v1.2.3-55-g6feb