aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-17 09:33:54 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-11-17 09:59:16 +0800
commit3ab0e296c674a6846512df24a0a70199bba8c59a (patch)
tree5335d463581b28ce793a8ce0ba7301532980b661 /src
parent5a67878e8684e02caf853137aae1dc367a77b48f (diff)
downloadrneovim-3ab0e296c674a6846512df24a0a70199bba8c59a.tar.gz
rneovim-3ab0e296c674a6846512df24a0a70199bba8c59a.tar.bz2
rneovim-3ab0e296c674a6846512df24a0a70199bba8c59a.zip
vim-patch:9.0.1969: [security] buffer-overflow in trunc_string()
Problem: buffer-overflow in trunc_string() Solution: Add NULL at end of buffer Currently trunc_string() assumes that when the string is too long, buf[e-1] will always be writeable. But that assumption may not always be true. The condition currently looks like this else if (e + 3 < buflen) [...] else { // can't fit in the "...", just truncate it buf[e - 1] = NUL; } but this means, we may run into the last else clause with e still being larger than buflen. So a buffer overflow occurs. So instead of using `buf[e - 1]`, let's just always truncate at `buf[buflen - 1]` which should always be writable. https://github.com/vim/vim/commit/3bd7fa12e146c6051490d048a4acbfba974eeb04 vim-patch:9.0.2004: Missing test file Problem: Missing test file Solution: git-add the file to the repo closes: vim/vim#13305 https://github.com/vim/vim/commit/d4afbdd0715c722cfc73d3a8ab9e578667615faa Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/message.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 8be8581537..ee1a9e60b0 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -468,7 +468,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen)
buf[e + 3 + len - 1] = NUL;
} else {
// can't fit in the "...", just truncate it
- buf[e - 1] = NUL;
+ buf[buflen - 1] = NUL;
}
}