Skip to content

Commit

Permalink
sanity check for empty directory strings
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Jun 20, 2024
1 parent 63f666a commit 8ee01eb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -13903,6 +13903,18 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType,
return ASN_PARSE_E;
}

#ifndef WOLFSSL_NO_ASN_STRICT
/* RFC 5280 section 4.1.2.4 lists a DirecotryString as being
* 1..MAX in length */
if (strLen < 1) {
WOLFSSL_MSG("Non conforming DirectoryString of length 0 was"
" found");
WOLFSSL_MSG("Use WOLFSSL_NO_ASN_STRICT if wanting to allow"
" empty DirectoryString's");
return ASN_PARSE_E;
}
#endif

if (id == ASN_COMMON_NAME) {
if (nameType == SUBJECT) {
cert->subjectCN = (char *)&input[srcIdx];
Expand Down Expand Up @@ -14533,6 +14545,18 @@ static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType,
/* Get string reference. */
GetASN_GetRef(&dataASN[RDNASN_IDX_ATTR_VAL], &str, &strLen);

#ifndef WOLFSSL_NO_ASN_STRICT
/* RFC 5280 section 4.1.2.4 lists a DirecotryString as being
* 1..MAX in length */
if (ret == 0 && strLen < 1) {
WOLFSSL_MSG("Non conforming DirectoryString of length 0 was"
" found");
WOLFSSL_MSG("Use WOLFSSL_NO_ASN_STRICT if wanting to allow"
" empty DirectoryString's");
ret = ASN_PARSE_E;
}
#endif

/* Convert BER tag to a OpenSSL type. */
switch (tag) {
case CTC_UTF8:
Expand Down

0 comments on commit 8ee01eb

Please sign in to comment.