diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-15 20:56:22 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-15 20:56:22 -0400 |
commit | b15230583c31799d650584b05f4cfce8cd726aea (patch) | |
tree | c9d56f3fd9bad409374302e6eb92e9343cb859c1 /core/Messenger.c | |
parent | 36cb9b003d2f9e8162c39ffa3ab1afa3743b13a4 (diff) |
Fixed loading and a small problem with the length of crypto requests.
Diffstat (limited to 'core/Messenger.c')
-rw-r--r-- | core/Messenger.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/Messenger.c b/core/Messenger.c index bed59d4d..4ed8bc41 100644 --- a/core/Messenger.c +++ b/core/Messenger.c | |||
@@ -810,10 +810,18 @@ int Messenger_load(Messenger *m, uint8_t * data, uint32_t length) | |||
810 | 810 | ||
811 | uint32_t i; | 811 | uint32_t i; |
812 | for (i = 0; i < num; ++i) { | 812 | for (i = 0; i < num; ++i) { |
813 | if(temp[i].status != 0) { | 813 | if(temp[i].status >= 3) { |
814 | int fnum = m_addfriend_norequest(m, temp[i].client_id); | 814 | int fnum = m_addfriend_norequest(m, temp[i].client_id); |
815 | setfriendname(m, fnum, temp[i].name); | 815 | setfriendname(m, fnum, temp[i].name); |
816 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ | 816 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ |
817 | } else if (temp[i].status != 0) { | ||
818 | /* TODO: this is not a good way to do this. */ | ||
819 | uint8_t address[FRIEND_ADDRESS_SIZE]; | ||
820 | memcpy(address, temp[i].client_id, crypto_box_PUBLICKEYBYTES); | ||
821 | memcpy(address + crypto_box_PUBLICKEYBYTES, &(temp[i].friendrequest_nospam), sizeof(uint32_t)); | ||
822 | uint16_t checksum = address_checksum(address, FRIEND_ADDRESS_SIZE - sizeof(checksum)); | ||
823 | memcpy(address + crypto_box_PUBLICKEYBYTES + sizeof(uint32_t), &checksum, sizeof(checksum)); | ||
824 | m_addfriend(m, address, temp[i].info, temp[i].info_size); | ||
817 | } | 825 | } |
818 | } | 826 | } |
819 | free(temp); | 827 | free(temp); |