1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 01:43:01 +01:00

fix another possible buffer overflow

..
This commit is contained in:
Jfreegman 2014-06-01 13:36:23 -04:00
parent 848b4e9a4c
commit 7206a9ea73
3 changed files with 10 additions and 5 deletions

View File

@ -214,8 +214,11 @@ static void chat_onStatusMessageChange(ToxWindow *self, int32_t num, uint8_t *st
return;
StatusBar *statusbar = self->stb;
status[len] = '\0';
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", status);
len = strlen(statusbar->statusmsg);
statusbar->statusmsg_len = len;
strcpy(statusbar->statusmsg, status);
statusbar->statusmsg[len] = '\0';
}

View File

@ -162,9 +162,11 @@ static void friendlist_onStatusMessageChange(ToxWindow *self, int32_t num, uint8
if (len > TOX_MAX_STATUSMESSAGE_LENGTH || num >= max_friends_index)
return;
strcpy(friends[num].statusmsg, str);
friends[num].statusmsg[len] = '\0';
str[len] = '\0';
snprintf(friends[num].statusmsg, sizeof(friends[num].statusmsg), "%s", str);
len = strlen(friends[num].statusmsg);
friends[num].statusmsg_len = len;
friends[num].statusmsg[len] = '\0';
}
void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort)

View File

@ -74,7 +74,7 @@ void prompt_update_nick(ToxWindow *prompt, uint8_t *nick, uint16_t len)
{
StatusBar *statusbar = prompt->stb;
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
statusbar->nick_len = len;
statusbar->nick_len = strlen(statusbar->nick);
}
/* Updates own statusmessage in prompt statusbar */
@ -82,7 +82,7 @@ void prompt_update_statusmessage(ToxWindow *prompt, uint8_t *statusmsg, uint16_t
{
StatusBar *statusbar = prompt->stb;
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
statusbar->statusmsg_len = len;
statusbar->statusmsg_len = strlen(statusbar->statusmsg);
}
/* Updates own status in prompt statusbar */