]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0130: [security]: UAF if win_split_ins autocommands delete "wp" v9.1.0130
authorSean Dewar <6256228+seandewar@users.noreply.github.com>
Sat, 24 Feb 2024 09:20:24 +0000 (10:20 +0100)
committerChristian Brabandt <cb@256bit.org>
Sat, 24 Feb 2024 09:20:24 +0000 (10:20 +0100)
Problem:  heap-use-after-free in win_splitmove if Enter/Leave
          autocommands from win_split_ins immediately closes "wp".
Solution: check that "wp" is valid after win_split_ins.
          (Sean Dewar)

closes: #14078

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_window_cmd.vim
src/version.c
src/window.c

index a70fb790c57788006f0abcd1386598f77281fab0..917c43203c67fb5386d94039d952d96bf5bd24fb 100644 (file)
@@ -1191,6 +1191,15 @@ func Test_win_splitmove()
   call assert_equal(v:true, s:triggered)
   unlet! s:triggered
 
+  split
+  let close_win = winnr('#')
+  augroup WinSplitMove
+    au!
+    au WinEnter * ++once quit!
+  augroup END
+  call win_splitmove(close_win, winnr())
+  call assert_equal(0, win_id2win(close_win))
+
   au! WinSplitMove
   augroup! WinSplitMove
   %bw!
index 3ea94ee92a67ced1b2a4386e454ab849bfd1907d..b6e25e665abccfddd21b7d3acef1e95da2a366f9 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    130,
 /**/
     129,
 /**/
index 66a1d7de41dd01c96a94c2ab6180a2e7152c7f21..7123780c5239cdf525c43b03b0e1226d41d48f59 100644 (file)
@@ -1954,7 +1954,8 @@ win_splitmove(win_T *wp, int size, int flags)
     }
 
     // If splitting horizontally, try to preserve height.
-    if (size == 0 && !(flags & WSP_VERT))
+    // Note that win_split_ins autocommands may have immediately closed "wp"!
+    if (size == 0 && !(flags & WSP_VERT) && win_valid(wp))
     {
        win_setheight_win(height, wp);
        if (p_ea)