summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/group.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index 2fbd341c..f83cd5a2 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -978,6 +978,18 @@ static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, cons
978 if (memcmp(data + 1 + sizeof(uint16_t) * 2, g->identifier, GROUP_IDENTIFIER_LENGTH) != 0) 978 if (memcmp(data + 1 + sizeof(uint16_t) * 2, g->identifier, GROUP_IDENTIFIER_LENGTH) != 0)
979 return; 979 return;
980 980
981 uint16_t peer_number = rand(); /* TODO: what if two people enter the group at the same time and
982 are given the same peer_number by different nodes? */
983 unsigned int tries = 0;
984
985 while (get_peer_index(g, peer_number) != -1) {
986 peer_number = rand();
987 ++tries;
988
989 if (tries > 32)
990 return;
991 }
992
981 memcpy(&other_groupnum, data + 1, sizeof(uint16_t)); 993 memcpy(&other_groupnum, data + 1, sizeof(uint16_t));
982 other_groupnum = ntohs(other_groupnum); 994 other_groupnum = ntohs(other_groupnum);
983 995
@@ -985,7 +997,6 @@ static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, cons
985 uint8_t real_pk[crypto_box_PUBLICKEYBYTES], temp_pk[crypto_box_PUBLICKEYBYTES]; 997 uint8_t real_pk[crypto_box_PUBLICKEYBYTES], temp_pk[crypto_box_PUBLICKEYBYTES];
986 get_friendcon_public_keys(real_pk, temp_pk, g_c->fr_c, friendcon_id); 998 get_friendcon_public_keys(real_pk, temp_pk, g_c->fr_c, friendcon_id);
987 999
988 uint16_t peer_number = rand(); /* TODO: make it not random. */
989 addpeer(g_c, groupnum, real_pk, temp_pk, peer_number); 1000 addpeer(g_c, groupnum, real_pk, temp_pk, peer_number);
990 int close_index = add_conn_to_groupchat(g_c, friendcon_id, groupnum, 0, 1); 1001 int close_index = add_conn_to_groupchat(g_c, friendcon_id, groupnum, 0, 1);
991 1002