Maximum name lengths should now be the real maximum and not one byte less.

This commit is contained in:
irungentoo 2014-04-03 20:21:24 -04:00
parent c8ab29632b
commit 413933a846
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 3 additions and 5 deletions

View File

@ -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;

View File

@ -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)