diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/Messenger.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/Messenger.c b/core/Messenger.c index 272c5fa7..641dbf8e 100644 --- a/core/Messenger.c +++ b/core/Messenger.c | |||
@@ -99,16 +99,19 @@ int getclient_id(int friend_id, uint8_t *client_id) | |||
99 | client_id is the client id of the friend | 99 | client_id is the client id of the friend |
100 | data is the data and length is the length | 100 | data is the data and length is the length |
101 | returns the friend number if success | 101 | returns the friend number if success |
102 | return -1 if failure. */ | 102 | return -1 if key length is wrong. |
103 | return -2 if user's own key | ||
104 | return -3 if already a friend | ||
105 | return -4 for other*/ | ||
103 | int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) | 106 | int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) |
104 | { | 107 | { |
105 | if (length == 0 || length >= | 108 | if (length == 0 || length >= |
106 | (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) | 109 | (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) |
107 | return -1; | 110 | return -1; |
108 | if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) | 111 | if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) |
109 | return -1; | 112 | return -2; |
110 | if (getfriend_id(client_id) != -1) | 113 | if (getfriend_id(client_id) != -1) |
111 | return -1; | 114 | return -3; |
112 | uint32_t i; | 115 | uint32_t i; |
113 | for (i = 0; i <= numfriends; ++i) { | 116 | for (i = 0; i <= numfriends; ++i) { |
114 | if(friendlist[i].status == 0) { | 117 | if(friendlist[i].status == 0) { |
@@ -126,7 +129,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) | |||
126 | return i; | 129 | return i; |
127 | } | 130 | } |
128 | } | 131 | } |
129 | return -1; | 132 | return -4; |
130 | } | 133 | } |
131 | 134 | ||
132 | int m_addfriend_norequest(uint8_t * client_id) | 135 | int m_addfriend_norequest(uint8_t * client_id) |