add sanity check for null buffer after malloc in test case

This commit is contained in:
JacobBarthelmeh
2024-03-04 07:33:21 -07:00
parent 065bfb0172
commit 2708062d39

View File

@@ -28034,6 +28034,7 @@ static int test_wc_PKCS7_VerifySignedData_RSA(void)
signedBundle = XBADFILE;
}
if (buf != NULL) {
ExpectNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId));
ExpectIntEQ(wc_PKCS7_InitWithCert(pkcs7, NULL, 0), 0);
for (i = 0; i < signedBundleSz;) {
@@ -28054,9 +28055,10 @@ static int test_wc_PKCS7_VerifySignedData_RSA(void)
ExpectIntEQ(rc, PKCS7_SIGNEEDS_CHECK);
wc_PKCS7_Free(pkcs7);
pkcs7 = NULL;
}
/* now try with malformed bundle */
if (buf != NULL) {
ExpectNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId));
ExpectIntEQ(wc_PKCS7_InitWithCert(pkcs7, NULL, 0), 0);
buf[signedBundleSz - 2] = buf[signedBundleSz - 2] + 1;
@@ -28078,6 +28080,8 @@ static int test_wc_PKCS7_VerifySignedData_RSA(void)
ExpectIntEQ(rc, ASN_PARSE_E);
wc_PKCS7_Free(pkcs7);
pkcs7 = NULL;
}
if (buf != NULL)
XFREE(buf, HEAP_HINT, DYNAMIC_TYPE_FILE);
}