diff options
author | Neil Horman <nhorman@openssl.org> | 2023-11-22 12:16:54 -0500 |
---|---|---|
committer | Neil Horman <nhorman@openssl.org> | 2023-12-01 11:15:00 -0500 |
commit | 99ac52c299667334436880dc9ad834714c76a944 (patch) | |
tree | 03345eb992ec62770ad2fd024a30d342f46bce38 /test | |
parent | e934d62222e5848b01c78d873914336ee63d7479 (diff) |
Don't free aliased pointers in ctx cmp_ctx tests
Coverity recorded issues 1551739 and 1551737, a potential double free in the
tests. It occurs when the DUP operation fails in such a way val3_read is
returned as the same pointer as val2_read. Ideally it should never
happen, but resetting val3_read to 0 should satisfy coverity that there
is no issue here
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/22800)
(cherry picked from commit c8ca810da9c47d8cb6988fd14e1cb4e20b0877e8)
Diffstat (limited to 'test')
-rw-r--r-- | test/cmp_ctx_test.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/cmp_ctx_test.c b/test/cmp_ctx_test.c index 137f67331b..f38493b334 100644 --- a/test/cmp_ctx_test.c +++ b/test/cmp_ctx_test.c @@ -405,6 +405,7 @@ execute_CTX_##SETN##_##GETN##_##FIELD(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \ } else { \ if (DUP && val1_read == val1) { \ TEST_error("first set did not dup the value"); \ + val1_read = 0; \ res = 0; \ } \ if (DEFAULT(val1_read)) { \ @@ -433,6 +434,7 @@ execute_CTX_##SETN##_##GETN##_##FIELD(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \ } else { \ if (DUP && val2_read == val2) { \ TEST_error("second set did not dup the value"); \ + val2_read = 0; \ res = 0; \ } \ if (val2 == val1) { \ @@ -462,6 +464,7 @@ execute_CTX_##SETN##_##GETN##_##FIELD(OSSL_CMP_CTX_TEST_FIXTURE *fixture) \ } else { \ if (DUP && val3_read == val2_read) { \ TEST_error("third get did not create a new dup"); \ + val3_read = 0; \ res = 0; \ } \ } \ |