Squashed 'external/toxcore/c-toxcore/' changes from 1828c5356..c9cdae001

c9cdae001 fix(toxav): remove extra copy of video frame on encode
4f6d4546b test: Improve the fake network library.
a2581e700 refactor(toxcore): generate `Friend_Request` and `Dht_Nodes_Response`
2aaa11770 refactor(toxcore): use Tox_Memory in generated events
5c367452b test(toxcore): fix incorrect mutex in tox_scenario_get_time
8f92e710f perf: Add a timed limit of number of cookie requests.
695b6417a test: Add some more simulated network support.
815ae9ce9 test(toxcore): fix thread-safety in scenario framework
6d85c754e test(toxcore): add unit tests for net_crypto
9c22e79cc test(support): add SimulatedEnvironment for deterministic testing
f34fcb195 chore: Update windows Dockerfile to debian stable (trixie).
ece0e8980 fix(group_moderation): allow validating unsorted sanction list signatures
a4fa754d7 refactor: rename struct Packet to struct Net_Packet
d6f330f85 cleanup: Fix some warnings from coverity.
e206bffa2 fix(group_chats): fix sync packets reverting topics
0e4715598 test: Add new scenario testing framework.
668291f44 refactor(toxcore): decouple Network_Funcs from sockaddr via IP_Port
fc4396cef fix: potential division by zero in toxav and unsafe hex parsing
8e8b352ab refactor: Add nullable annotations to struct members.
7740bb421 refactor: decouple net_crypto from DHT
1936d4296 test: add benchmark for toxav audio and video
46bfdc2df fix: correct printf format specifiers for unsigned integers
REVERT: 1828c5356 fix(toxav): remove extra copy of video frame on encode

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: c9cdae001341e701fca980c9bb9febfeb95d2902
This commit is contained in:
Green Sky
2026-01-11 14:42:31 +01:00
parent e95f2cbb1c
commit 565efa4f39
328 changed files with 19057 additions and 13982 deletions

View File

@@ -1069,6 +1069,10 @@ static bool prune_gc_mod_list(GC_Chat *_Nonnull chat)
bool pruned_mod = false;
for (uint16_t i = 0; i < chat->moderation.num_mods; ++i) {
if (chat->moderation.mod_list[i] == nullptr) {
LOGGER_ERROR(chat->log, "Moderator list contains a null entry at index %u", i);
continue;
}
if (get_peer_number_of_sig_pk(chat, chat->moderation.mod_list[i]) == -1) {
memcpy(public_sig_key, chat->moderation.mod_list[i], SIG_PUBLIC_KEY_SIZE);
@@ -1622,6 +1626,9 @@ static bool send_lossless_group_packet(const GC_Chat *_Nonnull chat, GC_Connecti
}
if (length > MAX_GC_PACKET_CHUNK_SIZE) {
if (data == nullptr) {
return false;
}
return gcc_send_lossless_packet_fragments(chat, gconn, data, length, packet_type);
}
@@ -1719,6 +1726,9 @@ static bool unpack_gc_sync_announce(GC_Chat *_Nonnull chat, const uint8_t *_Nonn
uint32_t added_tcp_relays = 0;
for (uint8_t i = 0; i < announce.tcp_relays_count; ++i) {
if (chat->tcp_conn == nullptr) {
return false;
}
const int add_tcp_result = add_tcp_relay_connection(chat->tcp_conn, new_gconn->tcp_connection_num,
&announce.tcp_relays[i].ip_port,
announce.tcp_relays[i].public_key);
@@ -1733,6 +1743,9 @@ static bool unpack_gc_sync_announce(GC_Chat *_Nonnull chat, const uint8_t *_Nonn
}
if (!announce.ip_port_is_set && added_tcp_relays == 0) {
if (chat->tcp_conn == nullptr) {
return false;
}
gcc_mark_for_deletion(new_gconn, chat->tcp_conn, GC_EXIT_TYPE_DISCONNECTED, nullptr, 0);
LOGGER_ERROR(chat->log, "Sync error: Invalid peer connection info");
return false;
@@ -1760,6 +1773,9 @@ static int handle_gc_sync_response(const GC_Session *_Nonnull c, GC_Chat *_Nonnu
uint16_t length, void *_Nullable userdata)
{
if (length > 0) {
if (data == nullptr) {
return -1;
}
if (!unpack_gc_sync_announce(chat, data, length)) {
return -1;
}
@@ -2187,7 +2203,7 @@ static bool send_gc_invite_response_reject(const GC_Chat *_Nonnull chat, GC_Conn
* Return -3 if we fail to send an invite response.
* Return -4 if peer_number does not designate a valid peer.
*/
static int handle_gc_invite_request(GC_Chat *_Nonnull chat, uint32_t peer_number, const uint8_t *_Nullable data, uint16_t length)
static int handle_gc_invite_request(GC_Chat *_Nonnull chat, uint32_t peer_number, const uint8_t *_Nonnull data, uint16_t length)
{
if (chat->shared_state.version == 0) { // we aren't synced yet; ignore request
return 0;
@@ -3825,10 +3841,12 @@ static bool handle_gc_topic_validate(const GC_Chat *_Nonnull chat, const GC_Peer
}
}
if (topic_info->version == chat->shared_state.topic_lock) {
// always accept topic on initial connection
if (!mono_time_is_timeout(chat->mono_time, chat->time_connected, GC_PING_TIMEOUT)) {
return true;
if (topic_info->version == chat->shared_state.topic_lock ||
!mono_time_is_timeout(chat->mono_time, chat->time_connected, GC_PING_TIMEOUT)) {
if (chat->topic_prev_checksum == topic_info->checksum &&
!mono_time_is_timeout(chat->mono_time, chat->topic_time_set, GC_CONFIRMED_PEER_TIMEOUT)) {
LOGGER_DEBUG(chat->log, "Topic reversion (probable sync error)");
return false;
}
return true;
@@ -7241,13 +7259,15 @@ static bool init_gc_tcp_connection(const GC_Session *_Nonnull c, GC_Chat *_Nonnu
{
const Messenger *m = c->messenger;
chat->tcp_conn = new_tcp_connections(chat->log, chat->mem, chat->rng, m->ns, chat->mono_time, chat->self_secret_key.enc,
&m->options.proxy_info, c->tcp_np);
TCP_Connections *tcp_conn = new_tcp_connections(chat->log, chat->mem, chat->rng, m->ns, chat->mono_time, chat->self_secret_key.enc,
&m->options.proxy_info, c->tcp_np);
if (chat->tcp_conn == nullptr) {
if (tcp_conn == nullptr) {
return false;
}
chat->tcp_conn = tcp_conn;
add_tcp_relays_to_chat(c, chat);
set_packet_tcp_connection_callback(chat->tcp_conn, &handle_gc_tcp_packet, c->messenger);