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

string safety

This commit is contained in:
Jfreegman 2014-03-28 03:46:00 -04:00
parent 8c071fb208
commit 21c48bde5c
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 8 additions and 4 deletions

View File

@ -184,7 +184,8 @@ static void chat_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_t *nic
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
len = strlen(nick) + 1;
memcpy(self->name, nick, len);
strcpy(self->name, nick);
self->name[len-1] = '\0';
}
static void chat_onStatusChange(ToxWindow *self, Tox *m, int32_t num, uint8_t status)
@ -203,7 +204,8 @@ static void chat_onStatusMessageChange(ToxWindow *self, int32_t num, uint8_t *st
StatusBar *statusbar = self->stb;
statusbar->statusmsg_len = len;
memcpy(statusbar->statusmsg, status, len);
strcpy(statusbar->statusmsg, status);
statusbar->statusmsg[len-1] = '\0';
}
static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum,

View File

@ -135,8 +135,9 @@ static void friendlist_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_
return;
str[TOXIC_MAX_NAME_LENGTH] = '\0';
strcpy(friends[num].name, str);
len = strlen(str) + 1;
memcpy(friends[num].name, str, len);
friends[num].name[len-1] = '\0';
friends[num].namelength = len;
sort_friendlist_index();
}
@ -154,7 +155,8 @@ static void friendlist_onStatusMessageChange(ToxWindow *self, int32_t num, uint8
if (len > TOX_MAX_STATUSMESSAGE_LENGTH || num >= max_friends_index)
return;
memcpy(friends[num].statusmsg, str, len);
strcpy(friends[num].statusmsg, str);
friends[num].statusmsg[len-1] = '\0';
friends[num].statusmsg_len = len;
}