diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/group.c | 6 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 10 | ||||
-rw-r--r-- | toxcore/onion_announce.c | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index 26df82bd..24f0b72e 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -190,7 +190,7 @@ static int get_peer_index(Group_c *g, uint16_t peer_number) | |||
190 | 190 | ||
191 | static uint16_t calculate_comp_value(const uint8_t *pk1, const uint8_t *pk2) | 191 | static uint16_t calculate_comp_value(const uint8_t *pk1, const uint8_t *pk2) |
192 | { | 192 | { |
193 | uint8_t cmp1, cmp2; | 193 | uint8_t cmp1, cmp2 = 0; |
194 | 194 | ||
195 | for (cmp1 = crypto_box_PUBLICKEYBYTES; cmp1 != 0; --cmp1) { | 195 | for (cmp1 = crypto_box_PUBLICKEYBYTES; cmp1 != 0; --cmp1) { |
196 | uint8_t index = crypto_box_PUBLICKEYBYTES - cmp1; | 196 | uint8_t index = crypto_box_PUBLICKEYBYTES - cmp1; |
@@ -1025,7 +1025,7 @@ static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, cons | |||
1025 | return; | 1025 | return; |
1026 | 1026 | ||
1027 | uint16_t peer_number = rand(); /* TODO: what if two people enter the group at the same time and | 1027 | uint16_t peer_number = rand(); /* TODO: what if two people enter the group at the same time and |
1028 | are given the same peer_number by different nodes? */ | 1028 | are given the same peer_number by different nodes? */ |
1029 | unsigned int tries = 0; | 1029 | unsigned int tries = 0; |
1030 | 1030 | ||
1031 | while (get_peer_index(g, peer_number) != -1) { | 1031 | while (get_peer_index(g, peer_number) != -1) { |
@@ -1282,6 +1282,8 @@ static void handle_direct_packet(Group_Chats *g_c, int groupnumber, const uint8_ | |||
1282 | } | 1282 | } |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | break; | ||
1286 | |||
1285 | case PEER_QUERY_ID: { | 1287 | case PEER_QUERY_ID: { |
1286 | Group_c *g = get_group_c(g_c, groupnumber); | 1288 | Group_c *g = get_group_c(g_c, groupnumber); |
1287 | 1289 | ||
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 63012ce6..c83c5d54 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -835,8 +835,9 @@ static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, cons | |||
835 | 835 | ||
836 | if (send_data_packet_helper(c, crypt_connection_id, conn->recv_array.buffer_start, packet_num, data, length) == 0) { | 836 | if (send_data_packet_helper(c, crypt_connection_id, conn->recv_array.buffer_start, packet_num, data, length) == 0) { |
837 | Packet_Data *dt1 = NULL; | 837 | Packet_Data *dt1 = NULL; |
838 | get_data_pointer(&conn->send_array, &dt1, packet_num); | 838 | |
839 | dt1->time = temp_time; | 839 | if (get_data_pointer(&conn->send_array, &dt1, packet_num) == 1) |
840 | dt1->time = temp_time; | ||
840 | } else { | 841 | } else { |
841 | conn->maximum_speed_reached = 1; | 842 | conn->maximum_speed_reached = 1; |
842 | LOGGER_ERROR("send_data_packet failed\n"); | 843 | LOGGER_ERROR("send_data_packet failed\n"); |
@@ -1322,8 +1323,10 @@ static int create_crypto_connection(Net_Crypto *c) | |||
1322 | ++c->crypto_connections_length; | 1323 | ++c->crypto_connections_length; |
1323 | memset(&(c->crypto_connections[id]), 0, sizeof(Crypto_Connection)); | 1324 | memset(&(c->crypto_connections[id]), 0, sizeof(Crypto_Connection)); |
1324 | 1325 | ||
1325 | if (pthread_mutex_init(&c->crypto_connections[id].mutex, NULL) != 0) | 1326 | if (pthread_mutex_init(&c->crypto_connections[id].mutex, NULL) != 0) { |
1327 | pthread_mutex_unlock(&c->connections_mutex); | ||
1326 | return -1; | 1328 | return -1; |
1329 | } | ||
1327 | } | 1330 | } |
1328 | 1331 | ||
1329 | pthread_mutex_unlock(&c->connections_mutex); | 1332 | pthread_mutex_unlock(&c->connections_mutex); |
@@ -1817,6 +1820,7 @@ static int tcp_oob_callback(void *object, const uint8_t *public_key, const uint8 | |||
1817 | 1820 | ||
1818 | if (crypt_connection_id == -1) { | 1821 | if (crypt_connection_id == -1) { |
1819 | IP_Port source; | 1822 | IP_Port source; |
1823 | source.port = 0; | ||
1820 | source.ip.family = TCP_FAMILY; | 1824 | source.ip.family = TCP_FAMILY; |
1821 | source.ip.ip6.uint32[0] = location; | 1825 | source.ip.ip6.uint32[0] = location; |
1822 | 1826 | ||
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index b25b6b11..2b0de595 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -178,6 +178,9 @@ int send_data_request(Networking_Core *net, const Onion_Path *path, IP_Port dest | |||
178 | uint8_t packet[ONION_MAX_PACKET_SIZE]; | 178 | uint8_t packet[ONION_MAX_PACKET_SIZE]; |
179 | len = create_onion_packet(packet, sizeof(packet), path, dest, request, len); | 179 | len = create_onion_packet(packet, sizeof(packet), path, dest, request, len); |
180 | 180 | ||
181 | if (len == -1) | ||
182 | return -1; | ||
183 | |||
181 | if (sendpacket(net, path->ip_port1, packet, len) != len) | 184 | if (sendpacket(net, path->ip_port1, packet, len) != len) |
182 | return -1; | 185 | return -1; |
183 | 186 | ||