diff options
author | Christian Brabandt <cb@256bit.org> | 2024-08-01 22:10:28 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-08-01 22:35:18 +0200 |
commit | b29f4abcd4b3382fa746edd1d0562b7b48c9de60 (patch) | |
tree | 75aabcb648df422e96e18cd7c8c0fa9b4a50ded3 | |
parent | 8a0bbe7b8aad6f8da28dee218c01bc8a0185a2d5 (diff) |
patch 9.1.0648: [security] double-free in dialog_changed()v9.1.0648
Problem: [security] double-free in dialog_changed()
(SuyueGuo)
Solution: Only clear pointer b_sfname pointer, if it is different
than the b_ffname pointer. Don't try to free b_fname,
set it to NULL instead.
fixes: #15403
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-46pw-v7qw-xc2f
Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/ex_cmds2.c | 6 | ||||
-rw-r--r-- | src/testdir/crash/dialog_changed_uaf | bin | 0 -> 552 bytes | |||
-rw-r--r-- | src/testdir/test_crash.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index ce30b8d397..0d76b3b27a 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -197,9 +197,11 @@ dialog_changed( // restore to empty when write failed if (empty_bufname) { - VIM_CLEAR(buf->b_fname); + // prevent double free + if (buf->b_sfname != buf->b_ffname) + VIM_CLEAR(buf->b_sfname); + buf->b_fname = NULL; VIM_CLEAR(buf->b_ffname); - VIM_CLEAR(buf->b_sfname); unchanged(buf, TRUE, FALSE); } } diff --git a/src/testdir/crash/dialog_changed_uaf b/src/testdir/crash/dialog_changed_uaf Binary files differnew file mode 100644 index 0000000000..e37d18d6da --- /dev/null +++ b/src/testdir/crash/dialog_changed_uaf diff --git a/src/testdir/test_crash.vim b/src/testdir/test_crash.vim index 29061aa423..9aef245026 100644 --- a/src/testdir/test_crash.vim +++ b/src/testdir/test_crash.vim @@ -196,6 +196,12 @@ func Test_crash1_3() call term_sendkeys(buf, args) call TermWait(buf, 50) + let file = 'crash/dialog_changed_uaf' + let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'\<cr>" + let args = printf(cmn_args, vim, file) + call term_sendkeys(buf, args) + call TermWait(buf, 150) + " clean up exe buf .. "bw!" bw! diff --git a/src/version.c b/src/version.c index 0e49ebd7a0..3ca6001269 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 648, +/**/ 647, /**/ 646, |