mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:13:02 +01:00
off by 1 error
This commit is contained in:
parent
e419299487
commit
411ae8d0f5
10
src/chat.c
10
src/chat.c
@ -126,7 +126,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, uint8_t *msg, u
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, num, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t timefrmt[TIME_STR_SIZE];
|
||||
@ -175,7 +175,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, uint8_t *action,
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, num, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);;
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);;
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t timefrmt[TIME_STR_SIZE];
|
||||
@ -191,7 +191,7 @@ static void chat_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_t *nic
|
||||
if (self->num != num)
|
||||
return;
|
||||
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH);
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[len] = '\0';
|
||||
strcpy(self->name, nick);
|
||||
}
|
||||
@ -352,7 +352,7 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui
|
||||
uint8_t msg[MAX_STR_SIZE + TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, friendnumber, name);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
name[n_len] = '\0';
|
||||
|
||||
snprintf(msg, sizeof(msg), "%s has invited you to a group chat.\n"
|
||||
@ -916,7 +916,7 @@ ToxWindow new_chat(Tox *m, int32_t friendnum)
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
int len = tox_get_name(m, friendnum, name);
|
||||
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH);
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
|
||||
name[len] = '\0';
|
||||
strcpy(ret.name, name);
|
||||
|
@ -106,7 +106,7 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, uint8_t *
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
int n_len = tox_get_name(m, num, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t timefrmt[TIME_STR_SIZE];
|
||||
@ -137,7 +137,7 @@ static void friendlist_onNickChange(ToxWindow *self, Tox *m, int32_t num, uint8_
|
||||
if (len > TOX_MAX_NAME_LENGTH || num >= max_friends_index)
|
||||
return;
|
||||
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH);
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
|
||||
str[len] = '\0';
|
||||
strcpy(friends[num].name, str);
|
||||
@ -216,7 +216,7 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, num, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
@ -239,7 +239,7 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, uint8
|
||||
} else {
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, num, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
@ -547,7 +547,7 @@ static void friendlist_onAv(ToxWindow *self, ToxAv *av)
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
int n_len = tox_get_name(m, id, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
|
@ -335,8 +335,7 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
||||
return;
|
||||
}
|
||||
|
||||
if (len >= TOXIC_MAX_NAME_LENGTH)
|
||||
len = TOXIC_MAX_NAME_LENGTH;
|
||||
len = MIN(len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
|
||||
nick[len] = L'\0';
|
||||
|
||||
|
@ -164,7 +164,7 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
int n_len = tox_group_peername(m, groupnum, peernum, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH); /* enforce client max name length */
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1); /* enforce client max name length */
|
||||
nick[n_len] = '\0';
|
||||
|
||||
/* check if message contains own name and alert appropriately */
|
||||
@ -224,7 +224,7 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
n_len = tox_group_peername(m, groupnum, peernum, nick);
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
nick[n_len] = '\0';
|
||||
|
||||
uint8_t timefrmt[TIME_STR_SIZE];
|
||||
@ -268,7 +268,7 @@ static void copy_peernames(int gnum, uint8_t peerlist[][TOX_MAX_NAME_LENGTH], ui
|
||||
memcpy(&groupchats[gnum].peer_names[i*N], peerlist[i], N);
|
||||
uint16_t n_len = lengths[i];
|
||||
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
|
||||
groupchats[gnum].peer_names[i*N+n_len] = '\0';
|
||||
groupchats[gnum].peer_name_lengths[i] = n_len;
|
||||
|
@ -371,7 +371,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH];
|
||||
int n_len = tox_get_name(m, friendnum, nick);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH);
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH-1);
|
||||
|
||||
if (!nick[0]) {
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
Loading…
Reference in New Issue
Block a user