mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-16 23:13:03 +01:00
string safety
This commit is contained in:
parent
8c071fb208
commit
21c48bde5c
@ -184,7 +184,8 @@ static void chat_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_t *nic
|
|||||||
|
|
||||||
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
|
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
|
||||||
len = strlen(nick) + 1;
|
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)
|
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 *statusbar = self->stb;
|
||||||
statusbar->statusmsg_len = len;
|
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,
|
static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum,
|
||||||
|
@ -135,8 +135,9 @@ static void friendlist_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
str[TOXIC_MAX_NAME_LENGTH] = '\0';
|
str[TOXIC_MAX_NAME_LENGTH] = '\0';
|
||||||
|
strcpy(friends[num].name, str);
|
||||||
len = strlen(str) + 1;
|
len = strlen(str) + 1;
|
||||||
memcpy(friends[num].name, str, len);
|
friends[num].name[len-1] = '\0';
|
||||||
friends[num].namelength = len;
|
friends[num].namelength = len;
|
||||||
sort_friendlist_index();
|
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)
|
if (len > TOX_MAX_STATUSMESSAGE_LENGTH || num >= max_friends_index)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy(friends[num].statusmsg, str, len);
|
strcpy(friends[num].statusmsg, str);
|
||||||
|
friends[num].statusmsg[len-1] = '\0';
|
||||||
friends[num].statusmsg_len = len;
|
friends[num].statusmsg_len = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user