diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-17 09:33:54 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-11-17 09:59:16 +0800 |
commit | 3ab0e296c674a6846512df24a0a70199bba8c59a (patch) | |
tree | 5335d463581b28ce793a8ce0ba7301532980b661 /test/functional/legacy/messages_spec.lua | |
parent | 5a67878e8684e02caf853137aae1dc367a77b48f (diff) | |
download | rneovim-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 'test/functional/legacy/messages_spec.lua')
-rw-r--r-- | test/functional/legacy/messages_spec.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index a604e68822..7536506aa3 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -6,6 +6,7 @@ local exec = helpers.exec local feed = helpers.feed local meths = helpers.meths local nvim_dir = helpers.nvim_dir +local assert_alive = helpers.assert_alive before_each(clear) @@ -758,4 +759,9 @@ describe('messages', function() ]]) os.remove('b.txt') end) + + it('no crash when truncating overlong message', function() + pcall(command, 'source test/old/testdir/crash/vim_msg_trunc_poc') + assert_alive() + end) end) |