1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-06-26 20:47:45 +02:00

fix possible buffer overflow

This commit is contained in:
Jfreegman 2014-06-01 12:54:45 -04:00
parent d65d0a08aa
commit 848b4e9a4c
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 10 additions and 12 deletions

View File

@ -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;

View File

@ -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);
}
}