Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal: increase CSI max params to 24 to accept Kakoune sequence #5949

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

mitchellh
Copy link
Contributor

@mitchellh mitchellh commented Feb 23, 2025

See #5930

Kakoune sends a real SGR sequence with 17 parameters. Our previous max was 16 so we threw away the entire sequence. This commit increases the max rather than fundamentally addressing limitations.

Practically, it took us this long to witness a real world sequence that exceeded our previous limit. We may need to revisit this in the future, but this is an easy fix for now.

In the future, as the comment states in this diff, we should probably look into a rare slow path where we heap allocate to accept up to some larger size (but still would need a cap to avoid DoS). For now, increasing to 24 slightly increases our memory usage but shouldn't result in any real world issues.

See #5930

Kakoune sends a real SGR sequence with 17 parameters. Our previous max
was 16 so we through away the entire sequence. This commit increases the
max rather than fundamentally addressing limitations.

Practically, it took us this long to witness a real world sequence that
exceeded our previous limit. We may need to revisit this in the future,
but this is an easy fix for now.

In the future, as the comment states in this diff, we should probably
look into a rare slow path where we heap allocate to accept up to some
larger size (but still would need a cap to avoid DoS). For now,
increasing to 24 slightly increases our memory usage but shouldn't
result in any real world issues.
@mitchellh mitchellh requested a review from a team as a code owner February 23, 2025 04:43
@rockorager
Copy link
Collaborator

24 seems like a good cap. I think it's reasonably possible to hit, but agree that since it's taken so long to get past our 16 max it's unlikely.

  1. Reset at beginning ("0")
  2. RGB with colorspace is 6. Set fg, bg, and ul would be 18 total ("38:2::0:0:0")
  3. Assume we set underline since we set underline color, that's another 2 with styled underline
  4. Set up to three more attributes. There are 7 commonly available, but not all would make sense at the same time (eg invisible is a weird combo).

That puts us at a max of 28 if you were to try set everything possible at once.

@mitchellh mitchellh merged commit 2f63f84 into main Feb 23, 2025
58 checks passed
@mitchellh mitchellh deleted the push-xpzkmsvqmrvr branch February 23, 2025 15:12
@github-actions github-actions bot added this to the 1.2.0 milestone Feb 23, 2025
@mitchellh
Copy link
Contributor Author

That puts us at a max of 28 if you were to try set everything possible at once.

That's a good analysis and it may be worth going to 28 just for that but a part of me also just wants to wait and see what happens with 24. Theoretically it's just 28 for a reasonable, well-formed user. It can be infinite since you can set the same SGR multiple times in a single sequence. 😢 I don't think there is anything restricting that, anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants