aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-04-05 20:02:02 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-04-05 20:02:02 +0000
commit335bd3662830b307694aa2b84ea33105ea415e43 (patch)
treef1095434b01492a386b0d49f468e98392ff44257
parentMerge branch 'fix-error-message-for-key-binding-collisions' (diff)
parentosc: verify OSC 4/104 color index is valid (diff)
Merge branch 'osc-4-check-index-is-within-bounds'
Closes #434
-rw-r--r--CHANGELOG.md3
-rw-r--r--osc.c12
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 970c070b..caadf51b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -71,6 +71,9 @@
when output scaling was enabled
(https://codeberg.org/dnkl/foot/issues/409).
* Empty sixels resulted in non-empty images.
+* OSC-4/104 out-of-bounds accesses to the color table. This was the
+ reason pywal turned foot windows transparent
+ (https://codeberg.org/dnkl/foot/issues/434).
## 1.7.0
diff --git a/osc.c b/osc.c
index bf97db52..68783701 100644
--- a/osc.c
+++ b/osc.c
@@ -575,6 +575,11 @@ osc_dispatch(struct terminal *term)
idx += c - '0';
}
+ if (idx >= ALEN(term->colors.table)) {
+ LOG_WARN("invalid OSC 4 color index: %u", idx);
+ break;
+ }
+
/* Client queried for current value */
if (strlen(s_color) == 1 && s_color[0] == '?') {
uint32_t color = term->colors.table[idx];
@@ -698,7 +703,7 @@ osc_dispatch(struct terminal *term)
if (strlen(string) == 0) {
LOG_DBG("resetting all colors");
- for (size_t i = 0; i < 256; i++) {
+ for (size_t i = 0; i < ALEN(term->colors.table); i++) {
update_color_in_grids(
term, term->colors.table[i], term->colors.default_table[i]);
term->colors.table[i] = term->colors.default_table[i];
@@ -717,6 +722,11 @@ osc_dispatch(struct terminal *term)
idx += c - '0';
}
+ if (idx >= ALEN(term->colors.table)) {
+ LOG_WARN("invalid OSC 104 color index: %u", idx);
+ continue;
+ }
+
LOG_DBG("resetting color #%u", idx);
update_color_in_grids(
term, term->colors.table[idx], term->colors.default_table[idx]);