diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-17 08:40:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 08:40:02 +0800 |
commit | 6952b1951b6a60df8d477279f4451094fb51c413 (patch) | |
tree | b9ef8b5821c4c263f6d390ffeb4fa15b5f3ee2e4 /test | |
parent | 133a592d191719023a9151a489d80fcdbed93ed7 (diff) | |
download | rneovim-6952b1951b6a60df8d477279f4451094fb51c413.tar.gz rneovim-6952b1951b6a60df8d477279f4451094fb51c413.tar.bz2 rneovim-6952b1951b6a60df8d477279f4451094fb51c413.zip |
vim-patch:9.0.2107: [security]: FPE in adjust_plines_for_skipcol (#26082)
Problem: [security]: FPE in adjust_plines_for_skipcol
Solution: don't divide by zero, return zero
Prevent a floating point exception when calculating w_skipcol (which can
happen with a small window when the number option is set and cpo+=n).
Add a test to verify
https://github.com/vim/vim/commit/cb0b99f0672d8446585d26e998343dceca17d1ce
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/scroll_opt_spec.lua | 16 | ||||
-rw-r--r-- | test/old/testdir/test_scroll_opt.vim | 19 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua index d4e4702f5e..8ac1141c2b 100644 --- a/test/functional/legacy/scroll_opt_spec.lua +++ b/test/functional/legacy/scroll_opt_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local exec = helpers.exec local feed = helpers.feed +local assert_alive = helpers.assert_alive before_each(clear) @@ -1007,6 +1008,21 @@ describe('smoothscroll', function() ]]) end) + -- oldtest: Test_smoothscroll_crash() + it('does not crash with small window and cpo+=n', function() + screen:try_resize(40, 12) + exec([[ + 20 new + vsp + put =repeat('aaaa', 20) + set nu fdc=1 smoothscroll cpo+=n + vert resize 0 + exe "norm! 0\<c-e>" + ]]) + feed('2<C-E>') + assert_alive() + end) + it("works with virt_lines above and below", function() screen:try_resize(55, 7) exec([=[ diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index f428e77579..f2e7bc6b56 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -929,4 +929,23 @@ func Test_smoothscroll_cursor_top() call StopVimInTerminal(buf) endfunc +" Division by zero, shouldn't crash +func Test_smoothscroll_crash() + CheckScreendump + + let lines =<< trim END + 20 new + vsp + put =repeat('aaaa', 20) + set nu fdc=1 smoothscroll cpo+=n + vert resize 0 + exe "norm! 0\<c-e>" + END + call writefile(lines, 'XSmoothScrollCrash', 'D') + let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols:40}) + call term_sendkeys(buf, "2\<C-E>\<C-L>") + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |