summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 07504988..3308b1ed 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -186,6 +186,10 @@ int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t leng
186 186
187 uint8_t client_id[crypto_box_PUBLICKEYBYTES]; 187 uint8_t client_id[crypto_box_PUBLICKEYBYTES];
188 id_copy(client_id, address); 188 id_copy(client_id, address);
189
190 if (!public_key_valid(client_id))
191 return FAERR_BADCHECKSUM;
192
189 uint16_t check, checksum = address_checksum(address, FRIEND_ADDRESS_SIZE - sizeof(checksum)); 193 uint16_t check, checksum = address_checksum(address, FRIEND_ADDRESS_SIZE - sizeof(checksum));
190 memcpy(&check, address + crypto_box_PUBLICKEYBYTES + sizeof(uint32_t), sizeof(check)); 194 memcpy(&check, address + crypto_box_PUBLICKEYBYTES + sizeof(uint32_t), sizeof(check));
191 195
@@ -261,6 +265,9 @@ int32_t m_addfriend_norequest(Messenger *m, const uint8_t *client_id)
261 if (getfriend_id(m, client_id) != -1) 265 if (getfriend_id(m, client_id) != -1)
262 return -1; 266 return -1;
263 267
268 if (!public_key_valid(client_id))
269 return -1;
270
264 /* Resize the friend list if necessary. */ 271 /* Resize the friend list if necessary. */
265 if (realloc_friendlist(m, m->numfriends + 1) != 0) 272 if (realloc_friendlist(m, m->numfriends + 1) != 0)
266 return FAERR_NOMEM; 273 return FAERR_NOMEM;