dcs: xtgettcap: ignore queries with invalid hex encodings

When we receive an XTGETTCAP query, where the capability is not
correctly hex encoded, ignore it.

Before this patch, we echo:ed it back to the TTY inside an error
resonse.
This commit is contained in:
Daniel Eklöf 2023-09-25 16:37:32 +02:00
parent 54722369d8
commit 8a5f2915e9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 6 additions and 7 deletions

View file

@ -76,6 +76,8 @@
`BTN_LEFT+3` by default) ([#1364][1364]). `BTN_LEFT+3` by default) ([#1364][1364]).
* `file://` prefix from URI's are no longer stripped when * `file://` prefix from URI's are no longer stripped when
opened/activated ([#1474][1474]). opened/activated ([#1474][1474]).
* `XTGETTCAP` with capabilities that are not properly hex encoded will
be ignored, instead of echo:ed back to the TTY in an error response.
[1391]: https://codeberg.org/dnkl/foot/issues/1391 [1391]: https://codeberg.org/dnkl/foot/issues/1391
[1448]: https://codeberg.org/dnkl/foot/pulls/1448 [1448]: https://codeberg.org/dnkl/foot/pulls/1448

11
dcs.c
View file

@ -111,14 +111,11 @@ static void
xtgettcap_reply(struct terminal *term, const char *hex_cap_name, size_t len) xtgettcap_reply(struct terminal *term, const char *hex_cap_name, size_t len)
{ {
char *name = hex_decode(hex_cap_name, len); char *name = hex_decode(hex_cap_name, len);
if (name == NULL) if (name == NULL) {
goto err; LOG_WARN("XTGETTCAP: invalid hex encoding, ignoring capability");
return;
}
#if 0
const struct foot_terminfo_entry *entry =
bsearch(name, terminfo_capabilities, ALEN(terminfo_capabilities),
sizeof(*entry), &terminfo_entry_compar);
#endif
const char *value; const char *value;
bool valid_capability = lookup_capability(name, &value); bool valid_capability = lookup_capability(name, &value);
xassert(!valid_capability || value != NULL); xassert(!valid_capability || value != NULL);