diff --git a/tests/suites/test_suite_pkcs7.function b/tests/suites/test_suite_pkcs7.function index 4c8bf233ef..52112a083d 100644 --- a/tests/suites/test_suite_pkcs7.function +++ b/tests/suites/test_suite_pkcs7.function @@ -121,12 +121,12 @@ void pkcs7_verify(char *pkcs7_file, TEST_EQUAL(res, 0); } - res = stat(filetobesigned, &st); - TEST_EQUAL(res, 0); - file = fopen(filetobesigned, "rb"); TEST_ASSERT(file != NULL); + res = fstat(fileno(file), &st); + TEST_EQUAL(res, 0); + datalen = st.st_size; /* Special-case for zero-length input so that data will be non-NULL */ TEST_CALLOC(data, datalen == 0 ? 1 : datalen);