mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.2107: [security]: FPE in adjust_plines_for_skipcol
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 Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
25aabc2b8e
commit
cb0b99f067
@ -45,8 +45,9 @@ adjust_plines_for_skipcol(win_T *wp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int width = wp->w_width - win_col_off(wp);
|
int width = wp->w_width - win_col_off(wp);
|
||||||
if (wp->w_skipcol >= width)
|
int w2 = width + win_col_off2(wp);
|
||||||
return (wp->w_skipcol - width) / (width + win_col_off2(wp)) + 1;
|
if (wp->w_skipcol >= width && w2 > 0)
|
||||||
|
return (wp->w_skipcol - width) / w2 + 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -926,4 +926,23 @@ func Test_smoothscroll_cursor_top()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2107,
|
||||||
/**/
|
/**/
|
||||||
2106,
|
2106,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user