1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-30 08:43:27 +01: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) { if (msg) {
strcpy(new_line->msg, msg); snprintf(new_line->msg, sizeof(new_line->msg), "%s", msg);
len += strlen(msg); len += strlen(new_line->msg);
} }
if (tmstmp) { if (tmstmp) {
strcpy(new_line->timestamp, tmstmp); snprintf(new_line->timestamp, sizeof(new_line->timestamp), "%s", tmstmp);
len += strlen(tmstmp); len += strlen(new_line->timestamp);
} }
if (name1) { if (name1) {
strcpy(new_line->name1, name1); snprintf(new_line->name1, sizeof(new_line->name1), "%s", name1);
len += strlen(name1); len += strlen(new_line->name1);
} }
if (name2) { if (name2) {
strcpy(new_line->name2, name2); snprintf(new_line->name2, sizeof(new_line->name2), "%s", name2);
len += strlen(name2); len += strlen(new_line->name2);
} }
new_line->len = len; new_line->len = len;

View File

@ -435,9 +435,7 @@ void refresh_inactive_windows(void)
for (i = 0; i < MAX_WINDOWS_NUM; ++i) { for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
ToxWindow *a = &windows[i]; ToxWindow *a = &windows[i];
if (!a->active || a == active_window || a->is_prompt) /* if prompt doesn't have scroll mode */ if (a->active && a != active_window && !a->is_prompt) /* if prompt doesn't have scroll mode */
continue;
line_info_print(a); line_info_print(a);
} }
} }