Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ static void SortCRL_CertList(RevokedCert* certs, int totalCerts)
}
#endif /* CRL_STATIC_REVOKED_LIST */

#if defined(OPENSSL_EXTRA)
/* Get length of date string. The parsed date is not guaranteed to be
* NUL-terminated, so stop at the end of the buffer. */
static int GetDateLen(const byte* date)
{
int len = 0;
while (len < MAX_DATE_SIZE && date[len] != 0)
len++;
return len;
}
#endif

/* Initialize CRL Entry */
static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
int verified, void* heap)
Expand All @@ -164,13 +176,12 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
crle->version = dcrl->version;

#if defined(OPENSSL_EXTRA)
crle->lastDateAsn1.length = MAX_DATE_SIZE;
XMEMCPY (crle->lastDateAsn1.data, crle->lastDate,
(size_t)crle->lastDateAsn1.length);
/* Set the actual date length, not MAX_DATE_SIZE. */
crle->lastDateAsn1.length = GetDateLen(crle->lastDate);
XMEMCPY (crle->lastDateAsn1.data, crle->lastDate, MAX_DATE_SIZE);
crle->lastDateAsn1.type = crle->lastDateFormat;
crle->nextDateAsn1.length = MAX_DATE_SIZE;
XMEMCPY (crle->nextDateAsn1.data, crle->nextDate,
(size_t)crle->nextDateAsn1.length);
crle->nextDateAsn1.length = GetDateLen(crle->nextDate);
XMEMCPY (crle->nextDateAsn1.data, crle->nextDate, MAX_DATE_SIZE);
crle->nextDateAsn1.type = crle->nextDateFormat;

crle->issuer = NULL;
Expand Down
12 changes: 12 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -28167,6 +28167,9 @@ static int test_wolfSSL_X509_CRL(void)

XFILE fp = XBADFILE;
int i;
#ifndef NO_ASN_TIME
ASN1_TIME* nextUpdate = NULL;
#endif

for (i = 0; pem[i][0] != '\0'; i++)
{
Expand All @@ -28186,6 +28189,15 @@ static int test_wolfSSL_X509_CRL(void)
crl = NULL;
}
ExpectNotNull(crl);
#ifndef NO_ASN_TIME
/* Dates must have their actual length set, not MAX_DATE_SIZE.
* nextUpdate is optional so only check it when present. */
ExpectIntEQ(ASN1_TIME_check(X509_CRL_get0_lastUpdate(crl)), 1);
nextUpdate = X509_CRL_get0_nextUpdate(crl);
if (nextUpdate != NULL) {
ExpectIntEQ(ASN1_TIME_check(nextUpdate), 1);
}
#endif
X509_CRL_free(crl);
crl = NULL;
if (fp != XBADFILE) {
Expand Down
Loading