Skip to content

Commit 85e1e83

Browse files
Fix heap-buffer-overflow in CI fuzzing tests
The ASN1_STRING is not supposed to be used as a zero-terminated string. Therefore we need to check the string length explicitly and use memcmp instead of strcmp in ossl_x509_check_cert_time. Fixes a regression introduced by openssl#28623
1 parent c20d470 commit 85e1e83

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crypto/x509/x509_vfy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,8 +2174,8 @@ int ossl_x509_check_certificate_times(const X509_VERIFY_PARAM *vpm, X509 *x,
21742174
* 99991231235959Z.
21752175
*/
21762176
notafter = X509_get0_notAfter(x);
2177-
if (strcmp((const char *)ASN1_STRING_get0_data(notafter), "99991231235959Z")
2178-
== 0)
2177+
if (notafter->length == 15
2178+
&& memcmp(ASN1_STRING_get0_data(notafter), "99991231235959Z", 15) == 0)
21792179
return 1;
21802180

21812181
if (!ossl_x509_compare_asn1_time(vpm, notafter, &comparison)) {
@@ -2225,8 +2225,8 @@ int ossl_x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth)
22252225
* 99991231235959Z.
22262226
*/
22272227
notafter = X509_get0_notAfter(x);
2228-
if (strcmp((const char *)ASN1_STRING_get0_data(notafter), "99991231235959Z")
2229-
== 0)
2228+
if (notafter->length == 15
2229+
&& memcmp(ASN1_STRING_get0_data(notafter), "99991231235959Z", 15) == 0)
22302230
return 1;
22312231

22322232
i = ossl_x509_compare_asn1_time(vpm, notafter, &comparison);

0 commit comments

Comments
 (0)