Squashed 'external/toxcore/c-toxcore/' changes from e58eb27a8..1828c5356
1828c5356 fix(toxav): remove extra copy of video frame on encode b66b8ded6 refactor: improve group stability, moderation determinism, and DHT dual-stack handling 4fbd7c10a fix(toxav): fix heap buffer overflow in RTP video packet handling 809fe8c78 refactor(tox): make the `#define` consts int literals. 50d242a37 refactor(toxav): improve MSI safety and testability da1c13a2f fix(toxav): harden video processing and fix large frame handling 472825288 fix(toxav): fix multiple logic bugs in audio module dc963d9a9 fix(toxav): fix multiple bugs in bandwidth controller and add tests 3bf5778ef refactor(toxav): split out RTP module and add exhaustive unit tests b79b7d436 fix(autotools): add tox_log_level.h to public headers list ea2e34ff2 chore: Disable cirrus. We're out of quota again. b449ea2ed chore(ci): update azure runner image to windows-2022 windows-2019 is EOL e115b136d refactor: Make add_to_list non-recursive. REVERT: e58eb27a8 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 1828c5356b2daf1d5f680854e776d74b181d268c
This commit is contained in:
@@ -591,9 +591,18 @@ static bool client_or_ip_port_in_list(const Logger *_Nonnull log, const Mono_Tim
|
||||
|
||||
LOGGER_DEBUG(log, "coipil[%u]: switching public_key (ipv%d)", index, ip_version);
|
||||
|
||||
/* kill the other address, if it was set */
|
||||
const IPPTsPng empty_ipptspng = {{{{0}}}};
|
||||
*assoc = empty_ipptspng;
|
||||
/* kill the other address, if it was set.
|
||||
* We just updated `assoc` (which is either assoc4 or assoc6) with the new public_key.
|
||||
* If there was an association for the other IP version, it's now invalid for this new identity.
|
||||
*/
|
||||
if (ip_version == 4) {
|
||||
const IPPTsPng empty_ipptspng = {{{{0}}}};
|
||||
list[index].assoc6 = empty_ipptspng;
|
||||
} else {
|
||||
const IPPTsPng empty_ipptspng = {{{{0}}}};
|
||||
list[index].assoc4 = empty_ipptspng;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -601,27 +610,30 @@ bool add_to_list(
|
||||
Node_format *nodes_list, uint32_t length, const uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE],
|
||||
const IP_Port *ip_port, const uint8_t cmp_pk[CRYPTO_PUBLIC_KEY_SIZE])
|
||||
{
|
||||
uint8_t pk_cur[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
memcpy(pk_cur, pk, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
IP_Port ip_port_cur = *ip_port;
|
||||
|
||||
bool inserted = false;
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
Node_format *node = &nodes_list[i];
|
||||
|
||||
if (id_closest(cmp_pk, node->public_key, pk) == 2) {
|
||||
if (id_closest(cmp_pk, node->public_key, pk_cur) == 2) {
|
||||
uint8_t pk_bak[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
memcpy(pk_bak, node->public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
|
||||
const IP_Port ip_port_bak = node->ip_port;
|
||||
memcpy(node->public_key, pk, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
|
||||
node->ip_port = *ip_port;
|
||||
memcpy(node->public_key, pk_cur, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
node->ip_port = ip_port_cur;
|
||||
|
||||
if (i != length - 1) {
|
||||
add_to_list(nodes_list, length, pk_bak, &ip_port_bak, cmp_pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
memcpy(pk_cur, pk_bak, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
ip_port_cur = ip_port_bak;
|
||||
inserted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return inserted;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,12 +650,6 @@ static void get_close_nodes_inner(uint64_t cur_time, const uint8_t *_Nonnull pub
|
||||
|
||||
for (uint32_t i = 0; i < client_list_length; ++i) {
|
||||
const Client_data *const client = &client_list[i];
|
||||
|
||||
/* node already in list? */
|
||||
if (index_of_node_pk(nodes_list, MAX_SENT_NODES, client->public_key) != UINT32_MAX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const IPPTsPng *ipptp;
|
||||
|
||||
if (net_family_is_ipv4(sa_family)) {
|
||||
@@ -674,6 +680,11 @@ static void get_close_nodes_inner(uint64_t cur_time, const uint8_t *_Nonnull pub
|
||||
|
||||
#endif /* CHECK_ANNOUNCE_NODE */
|
||||
|
||||
/* node already in list? */
|
||||
if (index_of_node_pk(nodes_list, num_nodes, client->public_key) != UINT32_MAX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (num_nodes < MAX_SENT_NODES) {
|
||||
memcpy(nodes_list[num_nodes].public_key, client->public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
nodes_list[num_nodes].ip_port = ipptp->ip_port;
|
||||
@@ -2009,7 +2020,7 @@ static uint32_t foreach_ip_port(const DHT *_Nonnull dht, const DHT_Friend *_Nonn
|
||||
static bool send_packet_to_friend(const DHT *_Nonnull dht, const IP_Port *_Nonnull ip_port, uint32_t *_Nonnull n, void *_Nonnull userdata)
|
||||
{
|
||||
const Packet *packet = (const Packet *)userdata;
|
||||
const int retval = send_packet(dht->net, ip_port, *packet);
|
||||
const int retval = net_send_packet(dht->net, ip_port, *packet);
|
||||
|
||||
if ((uint32_t)retval == packet->length) {
|
||||
++*n;
|
||||
@@ -2078,7 +2089,7 @@ static uint32_t routeone_to_friend(const DHT *_Nonnull dht, const uint8_t *_Nonn
|
||||
}
|
||||
|
||||
const uint32_t rand_idx = random_range_u32(dht->rng, n);
|
||||
const int retval = send_packet(dht->net, &ip_list[rand_idx], *packet);
|
||||
const int retval = net_send_packet(dht->net, &ip_list[rand_idx], *packet);
|
||||
|
||||
if ((unsigned int)retval == packet->length) {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user