mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-29 06:56:44 +02:00
fix possible buffer overflows and undefined behaviour
This commit is contained in:
@ -178,7 +178,7 @@ int complete_line(ToxWindow *self, const void *list, int n_items, int size)
|
||||
int strt = ctx->pos - s_len;
|
||||
int diff = m_len - s_len + n_endchrs;
|
||||
|
||||
if (ctx->len + diff > MAX_STR_SIZE)
|
||||
if (ctx->len + diff >= MAX_STR_SIZE)
|
||||
return -1;
|
||||
|
||||
char tmpend[MAX_STR_SIZE];
|
||||
@ -220,7 +220,7 @@ static void complt_home_dir(ToxWindow *self, char *path)
|
||||
|
||||
int newlen = wcslen(wline);
|
||||
|
||||
if (ctx->len + newlen > MAX_STR_SIZE)
|
||||
if (ctx->len + newlen >= MAX_STR_SIZE)
|
||||
return;
|
||||
|
||||
wmemcpy(ctx->line, wline, newlen + 1);
|
||||
|
Reference in New Issue
Block a user