mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:13:01 +01:00
fix possible buffer overflow
This commit is contained in:
parent
d65d0a08aa
commit
848b4e9a4c
@ -138,23 +138,23 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na
|
||||
}
|
||||
|
||||
if (msg) {
|
||||
strcpy(new_line->msg, msg);
|
||||
len += strlen(msg);
|
||||
snprintf(new_line->msg, sizeof(new_line->msg), "%s", msg);
|
||||
len += strlen(new_line->msg);
|
||||
}
|
||||
|
||||
if (tmstmp) {
|
||||
strcpy(new_line->timestamp, tmstmp);
|
||||
len += strlen(tmstmp);
|
||||
snprintf(new_line->timestamp, sizeof(new_line->timestamp), "%s", tmstmp);
|
||||
len += strlen(new_line->timestamp);
|
||||
}
|
||||
|
||||
if (name1) {
|
||||
strcpy(new_line->name1, name1);
|
||||
len += strlen(name1);
|
||||
snprintf(new_line->name1, sizeof(new_line->name1), "%s", name1);
|
||||
len += strlen(new_line->name1);
|
||||
}
|
||||
|
||||
if (name2) {
|
||||
strcpy(new_line->name2, name2);
|
||||
len += strlen(name2);
|
||||
snprintf(new_line->name2, sizeof(new_line->name2), "%s", name2);
|
||||
len += strlen(new_line->name2);
|
||||
}
|
||||
|
||||
new_line->len = len;
|
||||
|
@ -435,10 +435,8 @@ void refresh_inactive_windows(void)
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
ToxWindow *a = &windows[i];
|
||||
|
||||
if (!a->active || a == active_window || a->is_prompt) /* if prompt doesn't have scroll mode */
|
||||
continue;
|
||||
|
||||
line_info_print(a);
|
||||
if (a->active && a != active_window && !a->is_prompt) /* if prompt doesn't have scroll mode */
|
||||
line_info_print(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user