]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
unit-tests: Don't use test data on stack for TLS socket tests
authorTobias Brunner <tobias@strongswan.org>
Tue, 13 Sep 2022 14:10:55 +0000 (16:10 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 15 Sep 2022 10:16:12 +0000 (12:16 +0200)
The stack of that function might not be valid anymore once data is read.

src/libtls/tests/suites/test_socket.c

index 2c75d9efc3a0a5b01a6a86f68a0b84d52f7efcd8..91ee58b975f7e7d54a53fb864640ab29b2890c5f 100644 (file)
@@ -647,6 +647,11 @@ static void run_echo_client(echo_server_config_t *config)
        server->destroy(server);
 }
 
+/**
+ * Data for echo test
+ */
+static chunk_t echo_data = chunk_from_chars(0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08);
+
 /**
  * Create server/peer configuration
  */
@@ -660,7 +665,7 @@ static echo_server_config_t *create_config(tls_version_t version, uint16_t port,
                .addr = "127.0.0.1",
                .port = port,
                .cauth = cauth,
-               .data = chunk_from_chars(0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08),
+               .data = echo_data,
        );
        return config;
 }