diff options
author | irungentoo <irungentoo@gmail.com> | 2015-02-21 21:33:34 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-02-21 21:33:34 -0500 |
commit | bca649fa676c4a867e7501ab43d59b95ecf96bd0 (patch) | |
tree | da732d5cd5cb2683d9f7989be873cf12704f9826 /toxcore/TCP_server.c | |
parent | c086a66725fc52aaa09de0463fb9dbae4e407eb7 (diff) |
Fixed possible TCP server bug.
Function returned success when should have returned failure.
Diffstat (limited to 'toxcore/TCP_server.c')
-rw-r--r-- | toxcore/TCP_server.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index e1c1c85c..6d2ab62b 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -863,11 +863,16 @@ static int confirm_TCP_connection(TCP_Server *TCP_server, TCP_Secure_Connection | |||
863 | { | 863 | { |
864 | int index = add_accepted(TCP_server, con); | 864 | int index = add_accepted(TCP_server, con); |
865 | 865 | ||
866 | if (index == -1) | 866 | if (index == -1) { |
867 | kill_TCP_connection(con); | ||
867 | return -1; | 868 | return -1; |
869 | } | ||
870 | |||
871 | memset(con, 0, sizeof(TCP_Secure_Connection)); | ||
868 | 872 | ||
869 | if (handle_TCP_packet(TCP_server, index, data, length) == -1) { | 873 | if (handle_TCP_packet(TCP_server, index, data, length) == -1) { |
870 | kill_accepted(TCP_server, index); | 874 | kill_accepted(TCP_server, index); |
875 | return -1; | ||
871 | } | 876 | } |
872 | 877 | ||
873 | return index; | 878 | return index; |
@@ -1076,15 +1081,7 @@ static int do_unconfirmed(TCP_Server *TCP_server, uint32_t i) | |||
1076 | kill_TCP_connection(conn); | 1081 | kill_TCP_connection(conn); |
1077 | return -1; | 1082 | return -1; |
1078 | } else { | 1083 | } else { |
1079 | int index_new; | 1084 | return confirm_TCP_connection(TCP_server, conn, packet, len); |
1080 | |||
1081 | if ((index_new = confirm_TCP_connection(TCP_server, conn, packet, len)) == -1) { | ||
1082 | kill_TCP_connection(conn); | ||
1083 | } else { | ||
1084 | memset(conn, 0, sizeof(TCP_Secure_Connection)); | ||
1085 | } | ||
1086 | |||
1087 | return index_new; | ||
1088 | } | 1085 | } |
1089 | } | 1086 | } |
1090 | 1087 | ||