diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2025-01-02 07:58:48 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-01-02 07:58:48 +0000 |
| commit | c7ab7b353996634c61abd7cd66d32459a6e3da4e (patch) | |
| tree | 76aa21761bf2bc667bb66df97ec984e64f1c1964 | |
| parent | changelog: add missing issue ref (diff) | |
term: limit app-id to 2048 characters
Unsure if the protocol imposes a limit (haven't found any
documentation), or if the issue is in the libwayland implementation,
or wlroots (triggers in at least sway+river).
The issue is that setting a too long app-id causes the
compositor (river at least) to peg the CPU at 100%, and stop sending
e.g. frame callbacks to foot.
Closes #1897
| -rw-r--r-- | CHANGELOG.md | 7 | ||||
| -rw-r--r-- | terminal.c | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c824b82e..bdc1828b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,13 @@ ## Unreleased ### Added ### Changed + +* Runtime changes to the app-id (OSC-176) now limits the app-id string + to 2048 characters ([#1897][1897]). + +[1897]: https://codeberg.org/dnkl/foot/issues/1897 + + ### Deprecated ### Removed ### Fixed @@ -3588,8 +3588,10 @@ term_set_app_id(struct terminal *term, const char *app_id) { if (app_id != NULL && *app_id == '\0') app_id = NULL; + if (term->app_id == NULL && app_id == NULL) return; + if (term->app_id != NULL && app_id != NULL && streq(term->app_id, app_id)) return; @@ -3604,6 +3606,19 @@ term_set_app_id(struct terminal *term, const char *app_id) } else { term->app_id = NULL; } + + const size_t length = strlen(app_id); + if (length > 2048) { + /* + * Not sure if there's a limit in the protocol, or the + * libwayland implementation, or e.g. wlroots, but too long + * app-id's (not e.g. title) causes at least river and sway to + * peg the CPU at 100%, and stop sending e.g. frame callbacks. + * + */ + term->app_id[2048] = '\0'; + } + render_refresh_app_id(term); render_refresh_icon(term); } |
