Mercurial > vim
comparison src/testdir/test_crash.vim @ 33864:6e4c686b6b5b v9.0.2142
patch 9.0.2142: [security]: stack-buffer-overflow in option callback functions
Commit: https://github.com/vim/vim/commit/b39b240c386a5a29241415541f1c99e2e6b8ce47
Author: Christian Brabandt <cb@256bit.org>
Date: Wed Nov 29 11:34:05 2023 +0100
patch 9.0.2142: [security]: stack-buffer-overflow in option callback functions
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 10 Dec 2023 15:16:04 +0100 |
parents | 3b8089d550eb |
children | 8cdb69ea3711 |
comparison
equal
deleted
inserted
replaced
33863:3b8089d550eb | 33864:6e4c686b6b5b |
---|---|
140 let args = printf(cmn_args, vim, file) | 140 let args = printf(cmn_args, vim, file) |
141 call term_sendkeys(buf, args .. | 141 call term_sendkeys(buf, args .. |
142 \ ' && echo "crash 3: [OK]" >> '.. result .. "\<cr>") | 142 \ ' && echo "crash 3: [OK]" >> '.. result .. "\<cr>") |
143 call TermWait(buf, 150) | 143 call TermWait(buf, 150) |
144 | 144 |
145 let file = 'crash/poc_did_set_langmap' | |
146 let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'" | |
147 let args = printf(cmn_args, vim, file) | |
148 call term_sendkeys(buf, args .. | |
149 \ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>") | |
150 call TermWait(buf, 150) | |
151 | |
145 " clean up | 152 " clean up |
146 exe buf .. "bw!" | 153 exe buf .. "bw!" |
147 | 154 |
148 exe "sp " .. result | 155 exe "sp " .. result |
149 | 156 |
150 let expected = [ | 157 let expected = [ |
151 \ 'crash 1: [OK]', | 158 \ 'crash 1: [OK]', |
152 \ 'crash 2: [OK]', | 159 \ 'crash 2: [OK]', |
153 \ 'crash 3: [OK]', | 160 \ 'crash 3: [OK]', |
161 \ 'crash 4: [OK]', | |
154 \ ] | 162 \ ] |
155 | 163 |
156 call assert_equal(expected, getline(1, '$')) | 164 call assert_equal(expected, getline(1, '$')) |
157 bw! | 165 bw! |
158 | 166 |