diff options
-rw-r--r-- | toxcore/Messenger.c | 9 | ||||
-rw-r--r-- | toxcore/tox.c | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 07893e02..b712d142 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -346,17 +346,18 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le | |||
346 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_NICKNAME, name, length); | 346 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_NICKNAME, name, length); |
347 | } | 347 | } |
348 | 348 | ||
349 | /* Set the name of a friend. | 349 | /* Set the name and name_length of a friend. |
350 | * | 350 | * |
351 | * return 0 if success. | 351 | * return 0 if success. |
352 | * return -1 if failure. | 352 | * return -1 if failure. |
353 | */ | 353 | */ |
354 | static int setfriendname(Messenger *m, int friendnumber, uint8_t *name) | 354 | static int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t len) |
355 | { | 355 | { |
356 | if (friend_not_valid(m, friendnumber)) | 356 | if (friend_not_valid(m, friendnumber)) |
357 | return -1; | 357 | return -1; |
358 | 358 | ||
359 | memcpy(m->friendlist[friendnumber].name, name, MAX_NAME_LENGTH); | 359 | m->friendlist[friendnumber].name_length = len; |
360 | memcpy(m->friendlist[friendnumber].name, name, len); | ||
360 | return 0; | 361 | return 0; |
361 | } | 362 | } |
362 | 363 | ||
@@ -1027,7 +1028,7 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length) | |||
1027 | for (i = 0; i < num; ++i) { | 1028 | for (i = 0; i < num; ++i) { |
1028 | if (temp[i].status >= 3) { | 1029 | if (temp[i].status >= 3) { |
1029 | int fnum = m_addfriend_norequest(m, temp[i].client_id); | 1030 | int fnum = m_addfriend_norequest(m, temp[i].client_id); |
1030 | setfriendname(m, fnum, temp[i].name); | 1031 | setfriendname(m, fnum, temp[i].name, temp[i].name_length); |
1031 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ | 1032 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ |
1032 | } else if (temp[i].status != 0) { | 1033 | } else if (temp[i].status != 0) { |
1033 | /* TODO: This is not a good way to do this. */ | 1034 | /* TODO: This is not a good way to do this. */ |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 83b19e9b..54bbd9f0 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -184,7 +184,7 @@ uint16_t tox_getselfname(void *tox, uint8_t *name, uint16_t nlen) | |||
184 | /* Get name of friendnumber and put it in name. | 184 | /* Get name of friendnumber and put it in name. |
185 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. | 185 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. |
186 | * | 186 | * |
187 | * return 0 if success. | 187 | * return length of name (with the NULL terminator) if success. |
188 | * return -1 if failure. | 188 | * return -1 if failure. |
189 | */ | 189 | */ |
190 | int tox_getname(void *tox, int friendnumber, uint8_t *name) | 190 | int tox_getname(void *tox, int friendnumber, uint8_t *name) |