comparison src/move.c @ 33774:f2dd85a2bfc0 v9.0.2107

patch 9.0.2107: [security]: FPE in adjust_plines_for_skipcol Commit: https://github.com/vim/vim/commit/cb0b99f0672d8446585d26e998343dceca17d1ce Author: Christian Brabandt <cb@256bit.org> Date: Tue Nov 14 20:05:59 2023 +0100 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>
author Christian Brabandt <cb@256bit.org>
date Thu, 16 Nov 2023 22:15:08 +0100
parents 6e4bf51ec635
children 28e1e956f42c
comparison
equal deleted inserted replaced
33773:087539ab4b70 33774:f2dd85a2bfc0
43 { 43 {
44 if (wp->w_skipcol == 0) 44 if (wp->w_skipcol == 0)
45 return 0; 45 return 0;
46 46
47 int width = wp->w_width - win_col_off(wp); 47 int width = wp->w_width - win_col_off(wp);
48 if (wp->w_skipcol >= width) 48 int w2 = width + win_col_off2(wp);
49 return (wp->w_skipcol - width) / (width + win_col_off2(wp)) + 1; 49 if (wp->w_skipcol >= width && w2 > 0)
50 return (wp->w_skipcol - width) / w2 + 1;
50 51
51 return 0; 52 return 0;
52 } 53 }
53 54
54 /* 55 /*