diff options
author | Roman Proskuryakov <humbug@deeptown.org> | 2016-01-24 05:55:25 +0300 |
---|---|---|
committer | Roman Proskuryakov <humbug@deeptown.org> | 2016-01-27 02:17:40 +0300 |
commit | 23b0c9cdedae01b09055a0476823e225680d3930 (patch) | |
tree | 065896349a6d6aa9aa6a2240aa746daf38d4545c /toxcore/TCP_server.c | |
parent | 7d66c700374c3f5d772a439b6706bf455c703fea (diff) |
fix: replace memset with sodium_memzero for sensitive data
Diffstat (limited to 'toxcore/TCP_server.c')
-rw-r--r-- | toxcore/TCP_server.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 79f59acd..d4944aed 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -169,7 +169,7 @@ static int del_accepted(TCP_Server *TCP_server, int index) | |||
169 | if (!bs_list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index)) | 169 | if (!bs_list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index)) |
170 | return -1; | 170 | return -1; |
171 | 171 | ||
172 | memset(&TCP_server->accepted_connection_array[index], 0, sizeof(TCP_Secure_Connection)); | 172 | sodium_memzero(&TCP_server->accepted_connection_array[index], sizeof(TCP_Secure_Connection)); |
173 | --TCP_server->num_accepted_connections; | 173 | --TCP_server->num_accepted_connections; |
174 | 174 | ||
175 | if (TCP_server->num_accepted_connections == 0) | 175 | if (TCP_server->num_accepted_connections == 0) |
@@ -447,7 +447,7 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const | |||
447 | static void kill_TCP_connection(TCP_Secure_Connection *con) | 447 | static void kill_TCP_connection(TCP_Secure_Connection *con) |
448 | { | 448 | { |
449 | kill_sock(con->sock); | 449 | kill_sock(con->sock); |
450 | memset(con, 0, sizeof(TCP_Secure_Connection)); | 450 | sodium_memzero(con, sizeof(TCP_Secure_Connection)); |
451 | } | 451 | } |
452 | 452 | ||
453 | static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *con, uint8_t con_number); | 453 | static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *con, uint8_t con_number); |
@@ -868,7 +868,7 @@ static int confirm_TCP_connection(TCP_Server *TCP_server, TCP_Secure_Connection | |||
868 | return -1; | 868 | return -1; |
869 | } | 869 | } |
870 | 870 | ||
871 | memset(con, 0, sizeof(TCP_Secure_Connection)); | 871 | sodium_memzero(con, sizeof(TCP_Secure_Connection)); |
872 | 872 | ||
873 | if (handle_TCP_packet(TCP_server, index, data, length) == -1) { | 873 | if (handle_TCP_packet(TCP_server, index, data, length) == -1) { |
874 | kill_accepted(TCP_server, index); | 874 | kill_accepted(TCP_server, index); |
@@ -1056,7 +1056,7 @@ static int do_incoming(TCP_Server *TCP_server, uint32_t i) | |||
1056 | kill_TCP_connection(conn_new); | 1056 | kill_TCP_connection(conn_new); |
1057 | 1057 | ||
1058 | memcpy(conn_new, conn_old, sizeof(TCP_Secure_Connection)); | 1058 | memcpy(conn_new, conn_old, sizeof(TCP_Secure_Connection)); |
1059 | memset(conn_old, 0, sizeof(TCP_Secure_Connection)); | 1059 | sodium_memzero(conn_old, sizeof(TCP_Secure_Connection)); |
1060 | ++TCP_server->unconfirmed_connection_queue_index; | 1060 | ++TCP_server->unconfirmed_connection_queue_index; |
1061 | 1061 | ||
1062 | return index_new; | 1062 | return index_new; |