aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-17 09:42:59 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-11-17 09:59:22 +0800
commitd49be1cd2893ad583361ac058279a471ad7877e5 (patch)
tree3d2b7f6df5920969cbf66d8ab656af1a6260a830 /src/nvim/buffer.c
parentb6200fbdf2035b09abfc0f94fba9c432bc0b9245 (diff)
downloadrneovim-d49be1cd2893ad583361ac058279a471ad7877e5.tar.gz
rneovim-d49be1cd2893ad583361ac058279a471ad7877e5.tar.bz2
rneovim-d49be1cd2893ad583361ac058279a471ad7877e5.zip
vim-patch:9.0.2010: [security] use-after-free from buf_contents_changed()
Problem: [security] use-after-free from buf_contents_changed() Solution: block autocommands https://github.com/vim/vim/commit/41e6f7d6ba67b61d911f9b1d76325cd79224753d Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 6617907f8f..6d5c7a1766 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -4223,6 +4223,10 @@ bool buf_contents_changed(buf_T *buf)
aco_save_T aco;
aucmd_prepbuf(&aco, newbuf);
+ // We don't want to trigger autocommands now, they may have nasty
+ // side-effects like wiping buffers
+ block_autocmds();
+
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
0, 0, (linenr_T)MAXLNUM,
@@ -4247,6 +4251,8 @@ bool buf_contents_changed(buf_T *buf)
wipe_buffer(newbuf, false);
}
+ unblock_autocmds();
+
return differ;
}