Skip to content

Commit a8ea8a8

Browse files
committed
Fix from review
1 parent 4a13896 commit a8ea8a8

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

tests/api/test_certman.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,6 +2576,9 @@ int test_wolfSSL_CertManagerRejectMD5Cert(void)
25762576

25772577
ExpectNotNull(der = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT,
25782578
DYNAMIC_TYPE_TMP_BUFFER));
2579+
if (der == NULL) {
2580+
goto cleanup;
2581+
}
25792582

25802583
/* Build a leaf certificate whose issuer is the built-in 2048-bit
25812584
* wolfSSL test CA and sign it with MD5+RSA using the matching CA
@@ -2604,16 +2607,19 @@ int test_wolfSSL_CertManagerRejectMD5Cert(void)
26042607
/* Load the SHA-256 signed CA cert as a trust anchor and attempt
26052608
* to verify the MD5-signed leaf: it must be rejected because
26062609
* HashForSignature() now returns HASH_TYPE_E for MD5 in verify mode,
2607-
* which surfaces as ASN_SIG_CONFIRM_E from ConfirmSignature(). */
2610+
* and wolfSSL_CertManagerVerifyBuffer() returns that error. */
26082611
ExpectNotNull(cm = wolfSSL_CertManagerNew());
2609-
ExpectIntEQ(wolfSSL_CertManagerLoadCABuffer(cm, ca_cert_der_2048,
2610-
sizeof_ca_cert_der_2048, WOLFSSL_FILETYPE_ASN1),
2611-
WOLFSSL_SUCCESS);
2612+
if (cm != NULL) {
2613+
ExpectIntEQ(wolfSSL_CertManagerLoadCABuffer(cm, ca_cert_der_2048,
2614+
sizeof_ca_cert_der_2048, WOLFSSL_FILETYPE_ASN1),
2615+
WOLFSSL_SUCCESS);
26122616

2613-
ExpectIntEQ(wolfSSL_CertManagerVerifyBuffer(cm, der, derSz,
2614-
WOLFSSL_FILETYPE_ASN1),
2615-
WC_NO_ERR_TRACE(HASH_TYPE_E));
2617+
ExpectIntEQ(wolfSSL_CertManagerVerifyBuffer(cm, der, derSz,
2618+
WOLFSSL_FILETYPE_ASN1),
2619+
WC_NO_ERR_TRACE(HASH_TYPE_E));
2620+
}
26162621

2622+
cleanup:
26172623
wolfSSL_CertManagerFree(cm);
26182624
XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
26192625
if (caKeyInit) wc_FreeRsaKey(&caKey);

0 commit comments

Comments
 (0)