diff options
author | Christian Brabandt <cb@256bit.org> | 2023-11-29 11:34:05 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-12-01 18:58:51 +0100 |
commit | b39b240c386a5a29241415541f1c99e2e6b8ce47 (patch) | |
tree | 25ac23d0f18efb91f00bc053d326fa8549e9d484 /src/testdir | |
parent | 0fb375aae608d7306b4baf9c1f906961f32e2abf (diff) |
patch 9.0.2142: [security]: stack-buffer-overflow in option callback functionsv9.0.2142
Problem: [security]: stack-buffer-overflow in option callback functions
Solution: pass size of errbuf down the call stack, use snprintf()
instead of sprintf()
We pass the error buffer down to the option callback functions, but in
some parts of the code, we simply use sprintf(buf) to write into the error
buffer, which can overflow.
So let's pass down the length of the error buffer and use sprintf(buf, size)
instead.
Reported by @henices, thanks!
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/crash/poc_did_set_langmap | 1 | ||||
-rw-r--r-- | src/testdir/test_crash.vim | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/testdir/crash/poc_did_set_langmap b/src/testdir/crash/poc_did_set_langmap new file mode 100644 index 0000000000..f77145b9d1 --- /dev/null +++ b/src/testdir/crash/poc_did_set_langmap @@ -0,0 +1 @@ +se lmap=°xÿ7sil;drlmap=°xÿ7sil;drmo: pm313"
\ No newline at end of file diff --git a/src/testdir/test_crash.vim b/src/testdir/test_crash.vim index eef1731454..1d4f435e4d 100644 --- a/src/testdir/test_crash.vim +++ b/src/testdir/test_crash.vim @@ -142,6 +142,13 @@ func Test_crash1_2() \ ' && echo "crash 3: [OK]" >> '.. result .. "\<cr>") call TermWait(buf, 150) + let file = 'crash/poc_did_set_langmap' + let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'" + let args = printf(cmn_args, vim, file) + call term_sendkeys(buf, args .. + \ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>") + call TermWait(buf, 150) + " clean up exe buf .. "bw!" @@ -151,6 +158,7 @@ func Test_crash1_2() \ 'crash 1: [OK]', \ 'crash 2: [OK]', \ 'crash 3: [OK]', + \ 'crash 4: [OK]', \ ] call assert_equal(expected, getline(1, '$')) |