From 4d4ef5eed536c373f93c766f4071e14665a9b00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 20 Apr 2024 08:19:58 +0200 Subject: [PATCH] dcs: XTGETTCAP: handle empty request If the XTGETTCAP request is empty (no capabilities in it), reply with an empty error reply. Closes #1694 --- CHANGELOG.md | 3 +++ dcs.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2851f7ba..7d7cd49b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,9 @@ * Crash when zooming in or out, with `dpi-aware=yes`, and the monitor's DPI is 0 (this is true for, for example, nested Wayland sessions, or in virtualized environments). +* No error response for empty `XTGETTCAP` request ([#1694][1694]). + +[1694]: https://codeberg.org/dnkl/foot/issues/1694 ### Security diff --git a/dcs.c b/dcs.c index 19cce3c2..4dccbdee 100644 --- a/dcs.c +++ b/dcs.c @@ -200,6 +200,12 @@ xtgettcap_unhook(struct terminal *term) const char *const end = (const char *)&term->vt.dcs.data[left]; const char *p = (const char *)term->vt.dcs.data; + if (p == NULL) { + /* Request is empty; send an error reply, without any capabilities */ + term_to_slave(term, "\033P0+r\033\\", 7); + return; + } + while (true) { const char *sep = memchr(p, ';', left); size_t cap_len;