From 79ea30a957af5435f3293e17c61e6cd957c6882b Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 23 Jun 2022 13:40:45 -0600 Subject: [PATCH] memory free on failure, spelling, better function name --- wolfcrypt/src/asn.c | 14 ++++++++++---- wolfssl/wolfcrypt/asn.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 37908ea62..4c6abe818 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -83,6 +83,7 @@ ASN Options: * WOLFSSL_SUBJ_DIR_ATTR: Enable support for SubjectDirectoryAttributes extension. * WOLFSSL_SUBJ_INFO_ACC: Enable support for SubjectInfoAccess extension. + * WOLFSSL_FPKI: Enable support for FPKI (Federal PKI) extensions. */ #ifndef NO_ASN @@ -14953,13 +14954,18 @@ static int DecodeSepHwAltName(DecodedCert* cert, const byte* input, idx += strLen; ret = GetOctetString(input, &idx, &strLen, sz); - if (ret < 0) + if (ret < 0) { + XFREE(cert->hwType, cert->heap, DYNAMIC_TYPE_X509_EXT); + cert->hwType = NULL; return ret; + } cert->hwSerialNum = (byte*)XMALLOC(strLen + 1, cert->heap, DYNAMIC_TYPE_X509_EXT); if (cert->hwSerialNum == NULL) { WOLFSSL_MSG("\tOut of Memory"); + XFREE(cert->hwType, cert->heap, DYNAMIC_TYPE_X509_EXT); + cert->hwType = NULL; return MEMORY_E; } @@ -21281,7 +21287,7 @@ int wc_GetPubKeyDerFromCert(struct DecodedCert* cert, * otherwise the search starts from the node after 'current' alt name. * Returns 0 on success */ -static DNS_entry* wc_GetAltName(struct DecodedCert* cert, int nameType, +static DNS_entry* FindAltName(struct DecodedCert* cert, int nameType, DNS_entry* current) { DNS_entry* entry; @@ -21312,7 +21318,7 @@ int wc_GetUUIDFromCert(struct DecodedCert* cert, byte* uuid, word32* uuidSz) DNS_entry* id = NULL; do { - id = wc_GetAltName(cert, ASN_URI_TYPE, id); + id = FindAltName(cert, ASN_URI_TYPE, id); if (id != NULL) { /* check if URI string matches expected format for UUID */ if (id->len != DEFAULT_UUID_SZ) { @@ -21349,7 +21355,7 @@ int wc_GetFASCNFromCert(struct DecodedCert* cert, byte* fascn, word32* fascnSz) DNS_entry* id = NULL; do { - id = wc_GetAltName(cert, ASN_OTHER_TYPE, id); + id = FindAltName(cert, ASN_OTHER_TYPE, id); if (id != NULL && id->oidSum == FASCN_OID) { if (fascn == NULL) { *fascnSz = id->len; diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index 3995f3b19..df5490afb 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -1290,7 +1290,7 @@ struct DNS_entry { char* ipString; /* human readable form of IP address */ #endif #ifdef WOLFSSL_FPKI - int oidSum; /* provid oid sum for verification */ + int oidSum; /* provide oid sum for verification */ #endif };