]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1992: [security] segfault in exmode v9.0.1992
authorChristian Brabandt <cb@256bit.org>
Thu, 5 Oct 2023 20:08:30 +0000 (22:08 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 5 Oct 2023 20:10:10 +0000 (22:10 +0200)
Problem:  segfault in exmode when redrawing
Solution: skip gui_scroll when exmode_active

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui.c
src/testdir/crash/crash_scrollbar [new file with mode: 0644]
src/testdir/test_crash.vim
src/version.c

index 1f546b2a75b57d53e5ec8420b896753fa33d57a8..9c9aa3cbecdcf94a5bd9cc24f697cd4426a61390 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -4397,6 +4397,7 @@ gui_do_scrollbar(
  * Scroll a window according to the values set in the globals
  * "current_scrollbar" and "scrollbar_value".
  * Return TRUE if the cursor in the current window moved or FALSE otherwise.
+ * may eventually cause a redraw using updateWindow
  */
     int
 gui_do_scroll(void)
@@ -4416,6 +4417,9 @@ gui_do_scroll(void)
     if (wp == NULL)
        // Couldn't find window
        return FALSE;
+    // don't redraw, LineOffset and similar are not valid!
+    if (exmode_active)
+       return FALSE;
 
     /*
      * Compute number of lines to scroll.  If zero, nothing to do.
diff --git a/src/testdir/crash/crash_scrollbar b/src/testdir/crash/crash_scrollbar
new file mode 100644 (file)
index 0000000..1de5905
--- /dev/null
@@ -0,0 +1,2 @@
+" this goes to insert mode and presses key k_VerScrollbar which may cause a redraw in exmode, which used ot crash Vim
+norm o\80ùX
index 5c83e3a2f5ffe366e0d2199edf82a7517410786e..9a80340c285d4f482ac814110787cd20b546760b 100644 (file)
@@ -72,6 +72,12 @@ func Test_crash1()
     \ '  || echo "crash 8: [OK]" >> X_crash1_result.txt' .. "\<cr>")
   call TermWait(buf, 3000)
 
+  let file = 'crash/crash_scrollbar'
+  let args = printf(cmn_args, vim, file)
+  call term_sendkeys(buf, args ..
+    \ '  && echo "crash 9: [OK]" >> X_crash1_result.txt' .. "\<cr>")
+  call TermWait(buf, 1000)
+
   " clean up
   exe buf .. "bw!"
 
@@ -86,6 +92,7 @@ func Test_crash1()
       \ 'crash 6: [OK]',
       \ 'crash 7: [OK]',
       \ 'crash 8: [OK]',
+      \ 'crash 9: [OK]',
       \ ]
 
   call assert_equal(expected, getline(1, '$'))
index 9b1c0b4e9298bd958c7f86843a5353121279468e..2bb134a3b922b39c6e862ea6285b71d07b78d64e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1992,
 /**/
     1991,
 /**/