]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: unit tests - Add ssl_iostream_context_cache_free() calls
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 16 Jun 2023 13:51:20 +0000 (16:51 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:09 +0000 (12:34 +0200)
These will be necessary after the following commit, because unit tests are
using ssl_iostream_test_settings_*() calls to fill settings into a variable
in stack. However, the settings pointers may be added to
iostream-ssl-context-cache where they would become invalid.

src/lib-http/test-http-payload.c
src/lib-smtp/test-smtp-client-errors.c
src/lib-smtp/test-smtp-payload.c
src/lib-ssl-iostream/test-iostream-ssl.c

index fa63c200fb9c4df49e0b2bbd2c7584c38c0dacec..c904bfc4759eca544adadb326713692098ff4f15 100644 (file)
@@ -1897,6 +1897,7 @@ test_run_sequential(
        http_client_set.max_pipelined_requests = 1;
 
        test_run_client_server(&http_client_set, &http_server_set, client_init);
+       ssl_iostream_context_cache_free();
 
        test_out_reason("sequential", (failure == NULL), failure);
 }
@@ -1927,6 +1928,7 @@ test_run_pipeline(
        http_client_set.max_pipelined_requests = 8;
 
        test_run_client_server(&http_client_set, &http_server_set, client_init);
+       ssl_iostream_context_cache_free();
 
        test_out_reason("pipeline", (failure == NULL), failure);
 }
@@ -1957,6 +1959,7 @@ test_run_parallel(
        http_client_set.max_pipelined_requests = 8;
 
        test_run_client_server(&http_client_set, &http_server_set, client_init);
+       ssl_iostream_context_cache_free();
 
        test_out_reason("parallel", (failure == NULL), failure);
 }
index 86ab48c73077aa0b90d0aa762ecf90baeb932956..50126163e5e3c208cda11d739fad82edfbd62de5 100644 (file)
@@ -45,6 +45,7 @@ struct server_connection {
        struct connection conn;
        void *context;
 
+       struct ssl_iostream_settings ssl_set;
        struct ssl_iostream *ssl_iostream;
 
        enum server_connection_state state;
@@ -3837,6 +3838,7 @@ static void test_invalid_ssl_certificate(void)
                               test_client_invalid_ssl_certificate,
                               test_server_invalid_ssl_certificate, 1,
                               test_dns_invalid_ssl_certificate);
+       ssl_iostream_context_cache_free();
        test_end();
 }
 
@@ -3931,7 +3933,6 @@ test_client_run(test_client_init_t client_test,
 static int
 server_connection_init_ssl(struct server_connection *conn)
 {
-       struct ssl_iostream_settings ssl_set;
        const char *error;
 
        if (!test_server_ssl)
@@ -3939,10 +3940,10 @@ server_connection_init_ssl(struct server_connection *conn)
 
        connection_input_halt(&conn->conn);
 
-       ssl_iostream_test_settings_server(&ssl_set);
+       ssl_iostream_test_settings_server(&conn->ssl_set);
 
        if (server_ssl_ctx == NULL &&
-           ssl_iostream_context_init_server(&ssl_set, &server_ssl_ctx,
+           ssl_iostream_context_init_server(&conn->ssl_set, &server_ssl_ctx,
                                             &error) < 0) {
                i_error("SSL context initialization failed: %s", error);
                return -1;
@@ -4178,6 +4179,7 @@ static void test_server_run(unsigned int index)
 
        if (server_ssl_ctx != NULL)
                ssl_iostream_context_unref(&server_ssl_ctx);
+       ssl_iostream_context_cache_free();
 }
 
 /*
index 1ae5b685abf952e9fd301c8e554d76215ea4873b..0f2a9d00c5babdcb963d59c54817c1c148ec3fc3 100644 (file)
@@ -1046,6 +1046,8 @@ test_run_scenarios(
 
        test_out_reason("parallel pipelining startls",
                        (failure == NULL), failure);
+
+       ssl_iostream_context_cache_free();
 }
 
 static void test_smtp_normal(void)
index e44b96d2b080707a50251855448dd50a91834e3d..75e321dbb2d93af39ef3c5b722df82d3ee091035 100644 (file)
@@ -375,6 +375,7 @@ static void test_iostream_ssl_handshake(void)
        idx++;
 
        io_loop_destroy(&ioloop);
+       ssl_iostream_context_cache_free();
 
        test_end();
 }
@@ -466,6 +467,7 @@ static void test_iostream_ssl_get_buffer_avail_size(void)
        destroy_test_endpoint(&server);
 
        io_loop_destroy(&ioloop);
+       ssl_iostream_context_cache_free();
 
        test_end();
 }
@@ -540,6 +542,7 @@ static void test_iostream_ssl_small_packets(void)
        destroy_test_endpoint(&client);
 
        io_loop_destroy(&ioloop);
+       ssl_iostream_context_cache_free();
 
        test_end();
 }