diff options
-rw-r--r-- | core/Messenger.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/Messenger.c b/core/Messenger.c index eb59b81a..49f638df 100644 --- a/core/Messenger.c +++ b/core/Messenger.c | |||
@@ -99,14 +99,15 @@ 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 key length is wrong. | 102 | return -1 if message length is too long |
103 | return -2 if user's own key | 103 | return -2 if user's own key |
104 | return -3 if already a friend | 104 | return -3 if already a friend |
105 | return -4 for other*/ | 105 | return -4 for other*/ |
106 | 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) |
107 | { | 107 | { |
108 | if (length == 0 || length >= | 108 | if (length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES |
109 | (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) | 109 | - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES |
110 | + crypto_box_ZEROBYTES)) | ||
110 | return -1; | 111 | return -1; |
111 | if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) | 112 | if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) |
112 | return -2; | 113 | return -2; |