mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Maximum name lengths should now be the real maximum and not one byte less.
This commit is contained in:
parent
c8ab29632b
commit
413933a846
|
@ -1934,7 +1934,7 @@ void do_friends(Messenger *m)
|
|||
}
|
||||
|
||||
case PACKET_ID_NICKNAME: {
|
||||
if (data_length >= MAX_NAME_LENGTH || data_length == 0)
|
||||
if (data_length > MAX_NAME_LENGTH || data_length == 0)
|
||||
break;
|
||||
|
||||
/* Make sure the NULL terminator is present. */
|
||||
|
@ -1946,7 +1946,7 @@ void do_friends(Messenger *m)
|
|||
if (m->friend_namechange)
|
||||
m->friend_namechange(m, i, data_terminated, data_length, m->friend_namechange_userdata);
|
||||
|
||||
memcpy(m->friendlist[i].name, data_terminated, data_length + 1);
|
||||
memcpy(m->friendlist[i].name, data_terminated, data_length);
|
||||
m->friendlist[i].name_length = data_length;
|
||||
|
||||
break;
|
||||
|
|
|
@ -335,7 +335,7 @@ int group_peername(Group_Chat *chat, int peernum, uint8_t *name)
|
|||
|
||||
static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t contents_len)
|
||||
{
|
||||
if (contents_len >= MAX_NICK_BYTES || contents_len == 0)
|
||||
if (contents_len > MAX_NICK_BYTES || contents_len == 0)
|
||||
return;
|
||||
|
||||
/* same name as already stored? */
|
||||
|
@ -344,8 +344,6 @@ static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t c
|
|||
return;
|
||||
|
||||
memcpy(chat->group[peernum].nick, contents, contents_len);
|
||||
/* Force null termination */
|
||||
chat->group[peernum].nick[contents_len] = 0;
|
||||
chat->group[peernum].nick_len = contents_len;
|
||||
|
||||
if (chat->peer_namelistchange != NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user