aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorMatthieu Coudron <mattator@gmail.com>2020-06-08 16:52:56 +0200
committerGitHub <noreply@github.com>2020-06-08 16:52:56 +0200
commitd8c5d122f1ba95bc71a78c5d70465bfa88623bd7 (patch)
tree55bdbe00fbf6cb84457ad7474392398e2c7eb281 /src/nvim/os
parent980b12edbabc573f72d762dde844a771cc705e84 (diff)
parente01fc33515d5cd3a9a595d0e6905bd16d3a861e5 (diff)
downloadrneovim-d8c5d122f1ba95bc71a78c5d70465bfa88623bd7.tar.gz
rneovim-d8c5d122f1ba95bc71a78c5d70465bfa88623bd7.tar.bz2
rneovim-d8c5d122f1ba95bc71a78c5d70465bfa88623bd7.zip
Merge pull request #12376 from erw7/fix-stack-overflow-on-input-enqueue
input: fix stack overflow
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/input.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index c1580c5fc3..b7878d9da8 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -188,8 +188,13 @@ size_t input_enqueue(String keys)
char *ptr = keys.data;
char *end = ptr + keys.size;
- while (rbuffer_space(input_buffer) >= 6 && ptr < end) {
- uint8_t buf[6] = { 0 };
+ while (rbuffer_space(input_buffer) >= 19 && ptr < end) {
+ // A "<x>" form occupies at least 1 characters, and produces up
+ // to 19 characters (1 + 5 * 3 for the char and 3 for a modifier).
+ // In the case of K_SPECIAL(0x80) or CSI(0x9B), 3 bytes are escaped and
+ // needed, but since the keys are UTF-8, so the first byte cannot be
+ // K_SPECIAL(0x80) or CSI(0x9B).
+ uint8_t buf[19] = { 0 };
unsigned int new_size
= trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true,
false);