1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-02 18:16:46 +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

@ -62,23 +62,6 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
if (friendnumber < 0 || friendnumber > MAX_FRIENDS_NUM)
return;
if (length >= TOXIC_MAX_NAME_LENGTH) { /* length includes null byte */
string[TOXIC_MAX_NAME_LENGTH] = L'\0';
length = TOXIC_MAX_NAME_LENGTH + 1;
tox_setfriendname(m, friendnumber, string, length);
}
/* Append friendnumber to duplicate nicks to guarantee uniqueness */
int n = get_friendnum(string);
if (n != friendnumber && n != -1) {
char n_buf[strlen(string)+4]; /* must have room for friendnum chars relative to MAX_FRIENDS_NUM */
snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
strcpy(string, n_buf);
length = strlen(n_buf) + 1;
tox_setfriendname(m, friendnumber, string, length);
}
int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {