Prevent potential use of uninitialised data in pkcs7 tests
Move the initialisation of the pkcs7 object to before the first possible test failure, otherwise failure in those tests could result in an uninitialised pointer being free'd. Found by coverity. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
9b9ac4c6ef
commit
45b6e5e69f
1 changed files with 2 additions and 1 deletions
|
@ -78,6 +78,8 @@ void pkcs7_verify(char *pkcs7_file,
|
|||
|
||||
MD_OR_USE_PSA_INIT();
|
||||
|
||||
mbedtls_pkcs7_init(&pkcs7);
|
||||
|
||||
/* crt_files are space seprated list */
|
||||
for (i = 0; i < strlen(crt_files); i++) {
|
||||
if (crt_files[i] == ' ') {
|
||||
|
@ -100,7 +102,6 @@ void pkcs7_verify(char *pkcs7_file,
|
|||
i = k;
|
||||
}
|
||||
|
||||
mbedtls_pkcs7_init(&pkcs7);
|
||||
for (i = 0; i < n_crts; i++) {
|
||||
TEST_CALLOC(crts[i], 1);
|
||||
mbedtls_x509_crt_init(crts[i]);
|
||||
|
|
Loading…
Reference in a new issue