mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed possible TCP server bug.
Function returned success when should have returned failure.
This commit is contained in:
parent
c086a66725
commit
bca649fa67
|
@ -863,11 +863,16 @@ static int confirm_TCP_connection(TCP_Server *TCP_server, TCP_Secure_Connection
|
||||||
{
|
{
|
||||||
int index = add_accepted(TCP_server, con);
|
int index = add_accepted(TCP_server, con);
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
|
kill_TCP_connection(con);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(con, 0, sizeof(TCP_Secure_Connection));
|
||||||
|
|
||||||
if (handle_TCP_packet(TCP_server, index, data, length) == -1) {
|
if (handle_TCP_packet(TCP_server, index, data, length) == -1) {
|
||||||
kill_accepted(TCP_server, index);
|
kill_accepted(TCP_server, index);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
@ -1076,15 +1081,7 @@ static int do_unconfirmed(TCP_Server *TCP_server, uint32_t i)
|
||||||
kill_TCP_connection(conn);
|
kill_TCP_connection(conn);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int index_new;
|
return confirm_TCP_connection(TCP_server, conn, packet, len);
|
||||||
|
|
||||||
if ((index_new = confirm_TCP_connection(TCP_server, conn, packet, len)) == -1) {
|
|
||||||
kill_TCP_connection(conn);
|
|
||||||
} else {
|
|
||||||
memset(conn, 0, sizeof(TCP_Secure_Connection));
|
|
||||||
}
|
|
||||||
|
|
||||||
return index_new;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user