mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
Merge pull request #7669 from JacobBarthelmeh/x509_dn
sanity check for empty directory strings
This commit is contained in:
@ -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];
|
||||
@ -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:
|
||||
|
Reference in New Issue
Block a user