Avoid passing -1 as friend connection to new groups.

Somehow it still works because the lower levels can deal with
inconsistent/broken state, but this lets us avoid that broken state in
the first place. If a friend connection doesn't exist, we don't add it to
our group.
This commit is contained in:
iphydf 2018-08-11 13:07:37 +00:00
parent c10d5ceeee
commit b77e407b6f
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -1492,7 +1492,13 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
memcpy(&other_groupnum, data + 1, sizeof(uint16_t));
other_groupnum = net_ntohs(other_groupnum);
int friendcon_id = getfriendcon_id(m, friendnumber);
const int friendcon_id = getfriendcon_id(m, friendnumber);
if (friendcon_id == -1) {
// TODO(iphydf): Log something?
return;
}
uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE], temp_pk[CRYPTO_PUBLIC_KEY_SIZE];
get_friendcon_public_keys(real_pk, temp_pk, g_c->fr_c, friendcon_id);