aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-12-10 13:52:40 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-12-10 14:29:24 +0800
commit7a7ed0c8ac2d66d695da5bd3f90536e8c5c11ccc (patch)
treef19dcf946b2166a42c780c704986221e0ae91681 /test
parentac230370f3de2925b3ca9443e8d52d7fc4311aba (diff)
downloadrneovim-7a7ed0c8ac2d66d695da5bd3f90536e8c5c11ccc.tar.gz
rneovim-7a7ed0c8ac2d66d695da5bd3f90536e8c5c11ccc.tar.bz2
rneovim-7a7ed0c8ac2d66d695da5bd3f90536e8c5c11ccc.zip
vim-patch:9.0.2122: [security]: prevent overflow in indenting
Problem: [security]: prevent overflow in indenting Solution: use long long and remove cast to (int) The shiftwidth option values are defined as being long. However, when calculating the actual amount of indent, we cast down to (int), which may cause the shiftwidth value to become negative and later it may even cause Vim to try to allocate a huge amount of memory. We already use long and long long variable types to calculate the indent (and detect possible overflows), so the cast to (int) seems superfluous and can be safely removed. So let's just remove the (int) cast and calculate the indent using longs. Additionally, the 'shiftwidth' option value is also used when determining the actual 'cino' options. There it can again cause another overflow, so make sure it is safe in parse_cino() as well. fixes: vim/vim#13554 closes: vim/vim#13555 https://github.com/vim/vim/commit/3770574e4a70e810add9929973c51f9070c8c851 Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_indent.vim15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/old/testdir/test_indent.vim b/test/old/testdir/test_indent.vim
index 6afc3ff405..0998b04443 100644
--- a/test/old/testdir/test_indent.vim
+++ b/test/old/testdir/test_indent.vim
@@ -288,4 +288,19 @@ func Test_indent_overflow_count()
close!
endfunc
+func Test_indent_overflow_count2()
+ throw 'skipped: Nvim does not support 64-bit number options'
+ new
+ " this only works, when long is 64bits
+ try
+ setl sw=0x180000000
+ catch /^Vim\%((\a\+)\)\=:E487:/
+ throw 'Skipped: value negative on this platform'
+ endtry
+ call setline(1, "\tabc")
+ norm! <<
+ call assert_equal(0, indent(1))
+ close!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab