Skip to content

Commit

Permalink
adapt rejoin packet code to split of type from identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz committed Aug 13, 2018
1 parent 4116cfe commit a14947c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,10 @@ static int try_send_rejoin(Group_Chats *g_c, uint32_t groupnumber, const uint8_t
return -1;
}

uint8_t packet[1 + GROUP_IDENTIFIER_LENGTH];
uint8_t packet[1 + 1 + GROUP_ID_LENGTH];
packet[0] = PACKET_ID_REJOIN_CONFERENCE;
memcpy(packet + 1, g->identifier, GROUP_IDENTIFIER_LENGTH);
packet[1] = g->type;
memcpy(packet + 2, g->id, GROUP_ID_LENGTH);

if (write_cryptpacket(friendconn_net_crypto(g_c->fr_c), friend_connection_crypt_connection_id(g_c->fr_c, friendcon_id),
packet, sizeof(packet), 0) == -1) {
Expand Down Expand Up @@ -1841,11 +1842,11 @@ static int handle_packet_online(Group_Chats *g_c, int friendcon_id, const uint8_
static int handle_packet_rejoin(Group_Chats *g_c, int friendcon_id, const uint8_t *data, uint16_t length,
void *userdata)
{
if (length < GROUP_IDENTIFIER_LENGTH) {
if (length < 1 + GROUP_ID_LENGTH) {
return -1;
}

const int32_t groupnum = get_group_num(g_c, data);
const int32_t groupnum = get_group_num(g_c, *data, data + 1);

Group_c *g = get_group_c(g_c, groupnum);

Expand All @@ -1866,7 +1867,7 @@ static int handle_packet_rejoin(Group_Chats *g_c, int friendcon_id, const uint8_
int close_index = add_conn_to_groupchat(g_c, friendcon_id, groupnum, 0, 1);

if (close_index != -1) {
send_packet_online(g_c->fr_c, friendcon_id, groupnum, g->identifier);
send_packet_online(g_c->fr_c, friendcon_id, groupnum, g->type, g->id);
g->close[close_index].introduced = true;
}

Expand Down

0 comments on commit a14947c

Please sign in to comment.