forked from wolfSSL/wolfssl
allow zero legnth asn names, remove weird subjectcn len as zero means we own, use stored flag instead
This commit is contained in:
@@ -1059,6 +1059,7 @@ void InitDecodedCert(DecodedCert* cert, byte* source, word32 inSz, void* heap)
|
||||
cert->signature = 0;
|
||||
cert->subjectCN = 0;
|
||||
cert->subjectCNLen = 0;
|
||||
cert->subjectCNStored = 0;
|
||||
cert->issuer[0] = '\0';
|
||||
cert->subject[0] = '\0';
|
||||
cert->source = source; /* don't own */
|
||||
@@ -1100,7 +1101,7 @@ void InitDecodedCert(DecodedCert* cert, byte* source, word32 inSz, void* heap)
|
||||
|
||||
void FreeDecodedCert(DecodedCert* cert)
|
||||
{
|
||||
if (cert->subjectCNLen == 0) /* 0 means no longer pointer to raw, we own */
|
||||
if (cert->subjectCNStored == 1)
|
||||
XFREE(cert->subjectCN, cert->heap, DYNAMIC_TYPE_SUBJECT_CN);
|
||||
if (cert->pubKeyStored == 1)
|
||||
XFREE(cert->publicKey, cert->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||
@@ -1363,10 +1364,6 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
cert->maxIdx) < 0)
|
||||
return ASN_PARSE_E;
|
||||
|
||||
if (strLen == 0) {
|
||||
CYASSL_MSG("Zero length name");
|
||||
return ASN_PARSE_E;
|
||||
}
|
||||
if (strLen > (int)(ASN_NAME_MAX - idx))
|
||||
return ASN_PARSE_E;
|
||||
|
||||
@@ -2342,7 +2339,7 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm)
|
||||
XMEMCPY(ptr, cert->subjectCN, cert->subjectCNLen);
|
||||
ptr[cert->subjectCNLen] = '\0';
|
||||
cert->subjectCN = ptr;
|
||||
cert->subjectCNLen = 0;
|
||||
cert->subjectCNStored = 1;
|
||||
}
|
||||
|
||||
if (cert->keyOID == RSAk && cert->pubKeySize > 0) {
|
||||
|
||||
Reference in New Issue
Block a user