1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-05 03:36:45 +02:00

adjusting max name length handling

This commit is contained in:
Jfreegman
2013-10-18 23:08:37 -04:00
parent fe0ccf52e9
commit 361c4cfafc
3 changed files with 9 additions and 20 deletions

View File

@ -42,6 +42,8 @@ static void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint
if (len >= TOX_MAX_NAME_LENGTH || num < 0 || num >= num_friends)
return;
str[TOXIC_MAX_NAME_LENGTH] = '\0';
len = strlen(str) + 1;
memcpy(friends[num].name, str, len);
friends[num].namelength = len;
}
@ -82,6 +84,9 @@ int friendlist_onFriendAdded(Tox *m, int num)
if (friends[i].namelength == -1 || friends[i].name[0] == '\0') {
strcpy((char *) friends[i].name, UNKNOWN_NAME);
friends[i].namelength = strlen(UNKNOWN_NAME) + 1;
} else { /* Enforce toxic's maximum name length */
friends[i].name[TOXIC_MAX_NAME_LENGTH] = '\0';
friends[i].namelength = strlen(friends[i].name) + 1;
}
if (i == num_friends)