diff options
author | Tomas Mraz <tomas@openssl.org> | 2023-06-07 13:29:01 +0200 |
---|---|---|
committer | Todd Short <todd.short@me.com> | 2023-06-11 01:23:59 +0200 |
commit | a3fcafb34994c4864d8dc92a88f9d8e354230d12 (patch) | |
tree | ba6c7c5c3f616457a18a5ec541a7a57da2c8e736 /test/x509_check_cert_pkey_test.c | |
parent | Coverity 1531836: Check return value of CRYPTO_atomic_add() (diff) | |
download | openssl-a3fcafb34994c4864d8dc92a88f9d8e354230d12.tar.xz openssl-a3fcafb34994c4864d8dc92a88f9d8e354230d12.zip |
Coverity 1529992: Check return value of sscanf()
Also moving the call to setup_tests() where it
fits better.
Diffstat (limited to 'test/x509_check_cert_pkey_test.c')
-rw-r--r-- | test/x509_check_cert_pkey_test.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/x509_check_cert_pkey_test.c b/test/x509_check_cert_pkey_test.c index c53f566d51..83f4cb563c 100644 --- a/test/x509_check_cert_pkey_test.c +++ b/test/x509_check_cert_pkey_test.c @@ -107,7 +107,7 @@ failed: } static const char *file; /* path of a cert/CRL/key file in PEM format */ -static const char *num; /* expected number of certs/CRLs/keys included */ +static int expected; /* expected number of certs/CRLs/keys included */ static int test_PEM_X509_INFO_read_bio(void) { @@ -115,13 +115,11 @@ static int test_PEM_X509_INFO_read_bio(void) STACK_OF(X509_INFO) *sk; X509_INFO *it; int i, count = 0; - int expected = 0; if (!TEST_ptr((in = BIO_new_file(file, "r")))) return 0; sk = PEM_X509_INFO_read_bio(in, NULL, NULL, ""); BIO_free(in); - sscanf(num, "%d", &expected); for (i = 0; i < sk_X509_INFO_num(sk); i++) { it = sk_X509_INFO_value(sk, i); if (it->x509 != NULL) @@ -160,9 +158,13 @@ int setup_tests(void) } if (test_get_argument_count() == 2) { + const char *num; /* expected number of certs/CRLs/keys included */ + if (!TEST_ptr(file = test_get_argument(0)) || !TEST_ptr(num = test_get_argument(1))) return 0; + if (!TEST_int_eq(sscanf(num, "%d", &expected), 1)) + return 0; ADD_TEST(test_PEM_X509_INFO_read_bio); return 1; } |