Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: potential endless loop under extremely high load #2364

Merged
merged 6 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ for:
only:
- job_name: static
before_build:
- conan install -if _build -o with_tests=True .
- conan install -if _build -o with_tests=False .
- matrix:
only:
- job_name: shared
before_build:
- conan install -if _build -o with_tests=True -o shared=True .
- conan install -if _build -o with_tests=False -o shared=True .

build_script:
- set CONAN_CPU_COUNT=50
Expand Down
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5cf49ad258527f6a2734a9d1f863084f66189338f47ca9d0a49482b4217577fb /usr/local/bin/tox-bootstrapd
1fadb7de1ccf46186e33c13343e2c67f4c84e78fadfbfbbc8f3ce70e670907f2 /usr/local/bin/tox-bootstrapd
2 changes: 1 addition & 1 deletion toxcore/TCP_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int read_packet_TCP_secure_connection(
return -1;
}

VLA(uint8_t, data_encrypted, *next_packet_length);
VLA(uint8_t, data_encrypted, (int) *next_packet_length);
const int len_packet = read_TCP_packet(logger, ns, sock, data_encrypted, *next_packet_length, ip_port);

if (len_packet == -1) {
Expand Down
13 changes: 8 additions & 5 deletions toxcore/TCP_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,12 +1033,15 @@ TCP_Server *new_TCP_server(const Logger *logger, const Random *rng, const Networ
non_null()
static void do_TCP_accept_new(TCP_Server *tcp_server)
{
for (uint32_t i = 0; i < tcp_server->num_listening_socks; ++i) {
Socket sock;
for (uint32_t sock_idx = 0; sock_idx < tcp_server->num_listening_socks; ++sock_idx) {

for (uint32_t connection_idx = 0; connection_idx < MAX_INCOMING_CONNECTIONS; ++connection_idx) {
const Socket sock = net_accept(tcp_server->ns, tcp_server->socks_listening[sock_idx]);

do {
sock = net_accept(tcp_server->ns, tcp_server->socks_listening[i]);
} while (accept_connection(tcp_server, sock) != -1);
if (accept_connection(tcp_server, sock) == -1) {
break;
}
}
}
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions toxcore/crypto_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool crypto_memunlock(void *data, size_t length)
#endif
}

bool pk_equal(const uint8_t *pk1, const uint8_t *pk2)
bool pk_equal(const uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE])
{
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
// Hope that this is better for the fuzzer
Expand All @@ -186,7 +186,7 @@ bool pk_equal(const uint8_t *pk1, const uint8_t *pk2)
#endif
}

void pk_copy(uint8_t *dest, const uint8_t *src)
void pk_copy(uint8_t dest[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t src[CRYPTO_PUBLIC_KEY_SIZE])
{
memcpy(dest, src, CRYPTO_PUBLIC_KEY_SIZE);
}
Expand Down Expand Up @@ -484,7 +484,7 @@ void crypto_derive_public_key(uint8_t *public_key, const uint8_t *secret_key)
crypto_scalarmult_curve25519_base(public_key, secret_key);
}

void new_hmac_key(const Random *rng, uint8_t *key)
void new_hmac_key(const Random *rng, uint8_t key[CRYPTO_HMAC_KEY_SIZE])
{
random_bytes(rng, key, CRYPTO_HMAC_KEY_SIZE);
}
Expand Down
1 change: 1 addition & 0 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ Tox_Connection tox_self_get_connection_status(const Tox *tox)
}

LOGGER_FATAL(tox->m->log, "impossible return value: %d", ret);
return TOX_CONNECTION_NONE;
}


Expand Down