Set actual date length in CRL ASN1_TIME fields - #11151
Conversation
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11151
Scan targets checked: wolfssl-bugs
Failed targets: wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenSSL-compat CRL time handling by setting WOLFSSL_ASN1_TIME.length to the actual date string length (instead of MAX_DATE_SIZE), restoring correct behavior for ASN1_TIME_check() and consumers of X509_CRL_get0_lastUpdate() / X509_CRL_get0_nextUpdate().
Changes:
- Set
CRL_Entry’slastDateAsn1.length/nextDateAsn1.lengthbased on the stored date string length rather thanMAX_DATE_SIZE. - Add API test coverage that validates CRL last/next update times pass
ASN1_TIME_check()(when ASN time support is enabled).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/api.c | Adds test assertions to validate CRL ASN1_TIME objects pass ASN1_TIME_check(). |
| src/crl.c | Fixes CRL entry ASN1_TIME length initialization to use the real date string length. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ExpectIntEQ(ASN1_TIME_check(X509_CRL_get0_lastUpdate(crl)), 1); | ||
| ExpectIntEQ(ASN1_TIME_check(X509_CRL_get0_nextUpdate(crl)), 1); |
There was a problem hiding this comment.
Thanks for catching that — updated.
The nextUpdate check is now guarded on non-NULL. lastUpdate (thisUpdate, mandatory per RFC 5280 §5.1) is still checked unconditionally.
| crle->lastDateAsn1.length = (int)XSTRLEN((const char*)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 = (int)XSTRLEN((const char*)crle->nextDate); | ||
| XMEMCPY (crle->nextDateAsn1.data, crle->nextDate, MAX_DATE_SIZE); |
There was a problem hiding this comment.
Good catch — you are right that the buffer is not guaranteed to be
NUL-terminated. Replaced XSTRLEN() with a bounded scan.
Description
lastDateAsn1/nextDateAsn1 used MAX_DATE_SIZE as the ASN1_TIME length
instead of the real date string length, breaking ASN1_TIME_check()
and date printing/comparison on X509_CRL_get0_lastUpdate()/
get0_nextUpdate(). Set the length with XSTRLEN() and add
ASN1_TIME_check() coverage to test_wolfSSL_X509_CRL().
Fixes zd#22281
Testing
Added length check on the time.
Checklist