From d58f88661f9973d9e016d6b81e575fdd4351fc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 22 Jul 2020 20:06:07 +0200 Subject: [PATCH 1/4] changelog: add new 'unreleased' section --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47cca36e..f9fa2a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.4.1](#1-4-1) * [1.4.0](#1-4-0) * [1.3.0](#1-3-0) @@ -9,6 +10,14 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Deprecated +### Removed +### Fixed +### Security + + ## 1.4.1 ### Fixed From 3869c7299fae34464317ebb71566859608e2c1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 22 Jul 2020 21:07:57 +0200 Subject: [PATCH 2/4] render: bump maximum window title length from 100 to 2048 (bytes) Apparently, the max is ~8K, but lets stay on the safe side. --- CHANGELOG.md | 5 +++++ render.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9fa2a2b..286b7836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ ## Unreleased ### Added +### Changed + +* Maximum window title length from 100 to 2048. + + ### Deprecated ### Removed ### Fixed diff --git a/render.c b/render.c index b71325f6..80611d22 100644 --- a/render.c +++ b/render.c @@ -1660,8 +1660,7 @@ render_search_box(struct terminal *term) static void render_update_title(struct terminal *term) { - /* TODO: figure out what the limit actually is */ - static const size_t max_len = 100; + static const size_t max_len = 2048; const char *title = term->window_title != NULL ? term->window_title : "foot"; char *copy = NULL; From fda6e9c2c9178be79d05509e0f7772ba742d8467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 23 Jul 2020 18:13:54 +0200 Subject: [PATCH 3/4] sixel: overwrite: use target sixel's height, not cell height When copying the image data for the left and right parts of the splitted images, use the sixel's height, not the cell height. This fixes a crash when the sixel didn't cover the entire cell height. --- CHANGELOG.md | 4 ++++ sixel.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286b7836..9ee46a87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ ### Deprecated ### Removed ### Fixed + +* Crash when overwriting a sixel and the row being overwritten did not + cover an entire cell. + ### Security diff --git a/sixel.c b/sixel.c index 7dab1fcc..d45bc916 100644 --- a/sixel.c +++ b/sixel.c @@ -272,7 +272,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six, (six->pos.row + rel_above) & (term->grid->num_rows - 1)}, }; imgs[2].data = malloc(imgs[2].width * imgs[2].height * sizeof(uint32_t)); - for (size_t i = 0; i < term->cell_height; i++) + for (size_t i = 0; i < imgs[2].height; i++) memcpy( &((uint32_t *)imgs[2].data)[i * imgs[2].width], &((const uint32_t *)six->data)[(rel_above * term->cell_height + i) * six->width], @@ -290,7 +290,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six, (six->pos.row + rel_above) & (term->grid->num_rows - 1)}, }; imgs[3].data = malloc(imgs[3].width * imgs[3].height * sizeof(uint32_t)); - for (size_t i = 0; i < term->cell_height; i++) + for (size_t i = 0; i < imgs[3].height; i++) memcpy( &((uint32_t *)imgs[3].data)[i * imgs[3].width], &((const uint32_t *)six->data)[(rel_above * term->cell_height + i) * six->width + rel_right * term->cell_width], From f6473756d959cfa35c7b9c47a5b66c288b791c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 23 Jul 2020 18:15:29 +0200 Subject: [PATCH 4/4] sixel: remove sixel-to-be-splitted *before* splitting it This fixes an assertion in debug builds, due to the pre-splitted and splitted sixels overlapping. --- CHANGELOG.md | 2 ++ sixel.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ee46a87..766d052a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ * Crash when overwriting a sixel and the row being overwritten did not cover an entire cell. +* Assertion failure in debug builds when overwriting a sixel image. + ### Security diff --git a/sixel.c b/sixel.c index d45bc916..ab9ad0e9 100644 --- a/sixel.c +++ b/sixel.c @@ -350,9 +350,11 @@ _sixel_overwrite_by_rectangle( (col <= col_end && col + width - 1 >= col_end) || (col >= col_start && col + width - 1 <= col_end)) { - sixel_overwrite(term, six, start, col, height, width); - sixel_erase(term, six); + struct sixel to_be_erased = *six; tll_remove(term->grid->sixel_images, it); + + sixel_overwrite(term, &to_be_erased, start, col, height, width); + sixel_erase(term, &to_be_erased); } } } @@ -421,9 +423,11 @@ sixel_overwrite_by_row(struct terminal *term, int _row, int col, int width) (col <= col_end && col + width - 1 >= col_end) || (col >= col_start && col + width - 1 <= col_end)) { - sixel_overwrite(term, six, row, col, 1, width); - sixel_erase(term, six); + struct sixel to_be_erased = *six; tll_remove(term->grid->sixel_images, it); + + sixel_overwrite(term, &to_be_erased, row, col, 1, width); + sixel_erase(term, &to_be_erased); } } }