diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2023-07-27 20:03:16 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2023-08-03 09:29:41 +0200 |
commit | 2c8d9f19e351a84d4329fbe2f68a4a8a49cad3ef (patch) | |
tree | 0e9a40b956fbee0840ee1f3f64332f389b10d319 /test/cmp_asn_test.c | |
parent | bdb1f6b74486daa1971b928528109a4c67cf2eb9 (diff) |
crypto/cmp: fix clash of OSSL_CMP_CERTREQID_NONE with error result of ossl_cmp_asn1_get_int()
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/21579)
Diffstat (limited to 'test/cmp_asn_test.c')
-rw-r--r-- | test/cmp_asn_test.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test/cmp_asn_test.c b/test/cmp_asn_test.c index 838bf19474..6dab3944b9 100644 --- a/test/cmp_asn_test.c +++ b/test/cmp_asn_test.c @@ -42,16 +42,28 @@ static void tear_down(CMP_ASN_TEST_FIXTURE *fixture) static int execute_cmp_asn1_get_int_test(CMP_ASN_TEST_FIXTURE *fixture) { - int res; + int res = 0; ASN1_INTEGER *asn1integer = ASN1_INTEGER_new(); + const int good_int = 77; + const int64_t max_int = INT_MAX; if (!TEST_ptr(asn1integer)) - return 0; - if (!TEST_true(ASN1_INTEGER_set(asn1integer, 77))) { + return res; + + if (!TEST_true(ASN1_INTEGER_set(asn1integer, good_int))) { ASN1_INTEGER_free(asn1integer); return 0; } - res = TEST_int_eq(77, ossl_cmp_asn1_get_int(asn1integer)); + res = TEST_int_eq(good_int, ossl_cmp_asn1_get_int(asn1integer)); + if (res == 0) + goto err; + + res = 0; + if (!TEST_true(ASN1_INTEGER_set_int64(asn1integer, max_int + 1))) + goto err; + res = TEST_int_eq(-2, ossl_cmp_asn1_get_int(asn1integer)); + + err: ASN1_INTEGER_free(asn1integer); return res; } |