summaryrefslogtreecommitdiff
path: root/auto_tests/TCP_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2017-01-20 21:16:55 +0000
committeriphydf <iphydf@users.noreply.github.com>2017-01-28 20:49:12 +0000
commit6ae33c16cf9e37fda85d70c78b3c2779eb8ca21a (patch)
tree99c3a8c26e02039b515bb6f57d2797d1cdf77c1d /auto_tests/TCP_test.c
parent895de7ef26e7617769f2271345e414545c2581f8 (diff)
Add VLA compatibility macro for C89-ish compilers.
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r--auto_tests/TCP_test.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index a1de4874..a5a70c4b 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -188,19 +188,19 @@ static void kill_TCP_con(struct sec_TCP_con *con)
188 188
189static int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, uint16_t length) 189static int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, uint16_t length)
190{ 190{
191 uint8_t packet[sizeof(uint16_t) + length + CRYPTO_MAC_SIZE]; 191 VLA(uint8_t, packet, sizeof(uint16_t) + length + CRYPTO_MAC_SIZE);
192 192
193 uint16_t c_length = htons(length + CRYPTO_MAC_SIZE); 193 uint16_t c_length = htons(length + CRYPTO_MAC_SIZE);
194 memcpy(packet, &c_length, sizeof(uint16_t)); 194 memcpy(packet, &c_length, sizeof(uint16_t));
195 int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t)); 195 int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t));
196 196
197 if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) { 197 if ((unsigned int)len != (SIZEOF_VLA(packet) - sizeof(uint16_t))) {
198 return -1; 198 return -1;
199 } 199 }
200 200
201 increment_nonce(con->sent_nonce); 201 increment_nonce(con->sent_nonce);
202 202
203 ck_assert_msg(send(con->sock, (const char *)packet, sizeof(packet), 0) == sizeof(packet), "send failed"); 203 ck_assert_msg(send(con->sock, (const char *)packet, SIZEOF_VLA(packet), 0) == SIZEOF_VLA(packet), "send failed");
204 return 0; 204 return 0;
205} 205}
206 206