2023-09-02 14:40:13 +02:00
|
|
|
" Some tests, that used to crash Vim
|
|
|
|
|
source check.vim
|
|
|
|
|
source screendump.vim
|
|
|
|
|
|
|
|
|
|
CheckScreendump
|
|
|
|
|
|
2025-02-13 20:55:45 +01:00
|
|
|
" Run the command in terminal and wait for it to complete via notification
|
|
|
|
|
func s:RunCommandAndWait(buf, cmd)
|
|
|
|
|
call term_sendkeys(a:buf, a:cmd .. "; printf '" .. TermNotifyParentCmd(v:false) .. "'\<cr>")
|
|
|
|
|
call WaitForChildNotification()
|
|
|
|
|
endfunc
|
|
|
|
|
|
2023-09-02 14:40:13 +02:00
|
|
|
func Test_crash1()
|
2023-09-05 07:45:04 +02:00
|
|
|
CheckNotBSD
|
2023-09-06 20:20:07 +02:00
|
|
|
CheckExecutable dash
|
2023-09-05 07:45:04 +02:00
|
|
|
|
2023-09-02 14:40:13 +02:00
|
|
|
" The following used to crash Vim
|
2023-09-03 09:23:12 +02:00
|
|
|
let opts = #{cmd: 'sh'}
|
|
|
|
|
let vim = GetVimProg()
|
2023-09-02 14:40:13 +02:00
|
|
|
|
2023-09-03 20:20:52 +02:00
|
|
|
let buf = RunVimInTerminal('sh', opts)
|
2023-09-02 14:40:13 +02:00
|
|
|
|
2023-09-03 09:23:12 +02:00
|
|
|
let file = 'crash/poc_huaf1'
|
|
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 1: [OK]" > X_crash1_result.txt')
|
2023-09-03 09:23:12 +02:00
|
|
|
|
|
|
|
|
let file = 'crash/poc_huaf2'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 2: [OK]" >> X_crash1_result.txt')
|
2023-09-03 09:23:12 +02:00
|
|
|
|
|
|
|
|
let file = 'crash/poc_huaf3'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 3: [OK]" >> X_crash1_result.txt')
|
2023-09-03 09:23:12 +02:00
|
|
|
|
2023-09-03 20:20:52 +02:00
|
|
|
let file = 'crash/bt_quickfix_poc'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 4: [OK]" >> X_crash1_result.txt')
|
2023-09-03 20:20:52 +02:00
|
|
|
" clean up
|
|
|
|
|
call delete('Xerr')
|
2023-09-03 09:23:12 +02:00
|
|
|
|
2023-09-03 21:24:33 +02:00
|
|
|
let file = 'crash/poc_tagfunc.vim'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2023-09-05 20:18:06 +02:00
|
|
|
" using || because this poc causes vim to exit with exitstatus != 0
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' || echo "crash 5: [OK]" >> X_crash1_result.txt')
|
2023-09-03 21:24:33 +02:00
|
|
|
|
|
|
|
|
|
2023-09-03 21:43:46 +02:00
|
|
|
let file = 'crash/bt_quickfix1_poc'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 6: [OK]" >> X_crash1_result.txt')
|
2023-09-03 21:43:46 +02:00
|
|
|
" clean up
|
|
|
|
|
call delete('X')
|
|
|
|
|
|
2023-09-05 20:18:06 +02:00
|
|
|
let file = 'crash/vim_regsub_both_poc'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 7: [OK]" >> X_crash1_result.txt')
|
2023-09-05 20:18:06 +02:00
|
|
|
|
2023-10-02 20:59:08 +02:00
|
|
|
let file = 'crash/vim_msg_trunc_poc'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' || echo "crash 8: [OK]" >> X_crash1_result.txt')
|
2023-10-02 20:59:08 +02:00
|
|
|
|
2023-10-05 22:08:30 +02:00
|
|
|
let file = 'crash/crash_scrollbar'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 9: [OK]" >> X_crash1_result.txt')
|
2023-10-05 22:08:30 +02:00
|
|
|
|
2023-10-11 21:08:13 +02:00
|
|
|
let file = 'crash/editing_arg_idx_POC_1'
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' || echo "crash 10: [OK]" >> X_crash1_result.txt')
|
2023-10-11 21:08:13 +02:00
|
|
|
call delete('Xerr')
|
|
|
|
|
call delete('@')
|
|
|
|
|
|
2023-09-03 09:23:12 +02:00
|
|
|
" clean up
|
2023-09-02 14:40:13 +02:00
|
|
|
exe buf .. "bw!"
|
|
|
|
|
|
2023-09-03 09:23:12 +02:00
|
|
|
sp X_crash1_result.txt
|
2023-09-03 20:20:52 +02:00
|
|
|
|
|
|
|
|
let expected = [
|
|
|
|
|
\ 'crash 1: [OK]',
|
|
|
|
|
\ 'crash 2: [OK]',
|
|
|
|
|
\ 'crash 3: [OK]',
|
|
|
|
|
\ 'crash 4: [OK]',
|
2023-09-03 21:24:33 +02:00
|
|
|
\ 'crash 5: [OK]',
|
2023-09-03 21:43:46 +02:00
|
|
|
\ 'crash 6: [OK]',
|
2023-09-05 20:18:06 +02:00
|
|
|
\ 'crash 7: [OK]',
|
2023-10-02 20:59:08 +02:00
|
|
|
\ 'crash 8: [OK]',
|
2023-10-05 22:08:30 +02:00
|
|
|
\ 'crash 9: [OK]',
|
2023-10-11 21:08:13 +02:00
|
|
|
\ 'crash 10: [OK]',
|
2023-09-03 20:20:52 +02:00
|
|
|
\ ]
|
|
|
|
|
|
|
|
|
|
call assert_equal(expected, getline(1, '$'))
|
2023-09-03 09:23:12 +02:00
|
|
|
bw!
|
|
|
|
|
|
|
|
|
|
call delete('X_crash1_result.txt')
|
2023-09-02 14:40:13 +02:00
|
|
|
endfunc
|
|
|
|
|
|
2023-11-14 19:31:34 +01:00
|
|
|
func Test_crash1_2()
|
|
|
|
|
CheckNotBSD
|
|
|
|
|
CheckExecutable dash
|
|
|
|
|
|
|
|
|
|
" The following used to crash Vim
|
|
|
|
|
let opts = #{cmd: 'sh'}
|
|
|
|
|
let vim = GetVimProg()
|
2023-11-30 11:32:18 +01:00
|
|
|
let result = 'X_crash1_2_result.txt'
|
2023-11-14 19:31:34 +01:00
|
|
|
|
|
|
|
|
let buf = RunVimInTerminal('sh', opts)
|
|
|
|
|
|
|
|
|
|
let file = 'crash/poc1'
|
|
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 1: [OK]" > '.. result)
|
2023-11-14 19:31:34 +01:00
|
|
|
|
2023-11-28 22:03:48 +01:00
|
|
|
let file = 'crash/poc_win_enter_ext'
|
|
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 2: [OK]" >> '.. result)
|
2023-11-28 22:03:48 +01:00
|
|
|
|
2023-11-29 10:23:39 +01:00
|
|
|
let file = 'crash/poc_suggest_trie_walk'
|
|
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
|
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' && echo "crash 3: [OK]" >> '.. result)
|
2023-11-29 10:23:39 +01:00
|
|
|
|
2023-11-29 11:34:05 +01:00
|
|
|
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)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' ; echo "crash 4: [OK]" >> '.. result)
|
2023-11-29 11:34:05 +01:00
|
|
|
|
2024-08-22 21:40:14 +02:00
|
|
|
let file = 'crash/reverse_text_overflow'
|
|
|
|
|
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)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args ..
|
|
|
|
|
\ ' ; echo "crash 5: [OK]" >> '.. result)
|
2024-08-22 21:40:14 +02:00
|
|
|
|
2023-11-14 19:31:34 +01:00
|
|
|
" clean up
|
|
|
|
|
exe buf .. "bw!"
|
|
|
|
|
exe "sp " .. result
|
|
|
|
|
let expected = [
|
|
|
|
|
\ 'crash 1: [OK]',
|
2023-11-28 22:03:48 +01:00
|
|
|
\ 'crash 2: [OK]',
|
2023-11-29 10:23:39 +01:00
|
|
|
\ 'crash 3: [OK]',
|
2023-11-29 11:34:05 +01:00
|
|
|
\ 'crash 4: [OK]',
|
2024-08-22 21:40:14 +02:00
|
|
|
\ 'crash 5: [OK]',
|
2023-11-14 19:31:34 +01:00
|
|
|
\ ]
|
|
|
|
|
|
|
|
|
|
call assert_equal(expected, getline(1, '$'))
|
|
|
|
|
bw!
|
|
|
|
|
call delete(result)
|
|
|
|
|
endfunc
|
|
|
|
|
|
2023-12-04 22:52:23 +01:00
|
|
|
" This test just runs various scripts, that caused issues before.
|
|
|
|
|
" We are not really asserting anything here, it's just important
|
|
|
|
|
" that ASAN does not detect any issues.
|
|
|
|
|
func Test_crash1_3()
|
|
|
|
|
let vim = GetVimProg()
|
|
|
|
|
let buf = RunVimInTerminal('sh', #{cmd: 'sh'})
|
|
|
|
|
|
|
|
|
|
let file = 'crash/poc_ex_substitute'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2023-12-04 22:52:23 +01:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2023-12-04 22:52:23 +01:00
|
|
|
|
|
|
|
|
let file = 'crash/poc_uaf_exec_instructions'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2023-12-04 22:52:23 +01:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2023-12-04 22:52:23 +01:00
|
|
|
|
2023-12-11 17:53:25 +01:00
|
|
|
let file = 'crash/poc_uaf_check_argument_types'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2023-12-11 17:53:25 +01:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2023-12-11 17:53:25 +01:00
|
|
|
|
2024-08-01 20:16:51 +02:00
|
|
|
let file = 'crash/double_free'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2024-08-01 20:16:51 +02:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2024-08-01 20:16:51 +02:00
|
|
|
|
2024-08-01 22:10:28 +02:00
|
|
|
let file = 'crash/dialog_changed_uaf'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2024-08-01 22:10:28 +02:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2024-08-01 22:10:28 +02:00
|
|
|
|
2024-08-11 20:09:17 +02:00
|
|
|
let file = 'crash/nullpointer'
|
2025-02-13 20:55:45 +01:00
|
|
|
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
|
2024-08-11 20:09:17 +02:00
|
|
|
let args = printf(cmn_args, vim, file)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2024-08-11 20:09:17 +02:00
|
|
|
|
2024-08-25 21:33:03 +02:00
|
|
|
let file = 'crash/heap_overflow3'
|
|
|
|
|
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)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2024-08-25 21:33:03 +02:00
|
|
|
|
2024-08-29 22:12:05 +02:00
|
|
|
let file = 'crash/heap_overflow_glob2regpat'
|
|
|
|
|
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)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2024-08-28 22:08:35 +02:00
|
|
|
|
2024-08-28 23:17:52 +02:00
|
|
|
let file = 'crash/nullptr_regexp_nfa'
|
|
|
|
|
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)
|
2025-02-13 20:55:45 +01:00
|
|
|
call s:RunCommandAndWait(buf, args)
|
2025-01-20 22:55:57 +01:00
|
|
|
|
2023-12-04 22:52:23 +01:00
|
|
|
" clean up
|
|
|
|
|
exe buf .. "bw!"
|
|
|
|
|
bw!
|
|
|
|
|
endfunc
|
|
|
|
|
|
2023-09-02 21:15:52 +02:00
|
|
|
func Test_crash2()
|
|
|
|
|
" The following used to crash Vim
|
|
|
|
|
let opts = #{wait_for_ruler: 0, rows: 20}
|
|
|
|
|
let args = ' -u NONE -i NONE -n -e -s -S '
|
|
|
|
|
let buf = RunVimInTerminal(args .. ' crash/vim_regsub_both', opts)
|
|
|
|
|
call VerifyScreenDump(buf, 'Test_crash_01', {})
|
|
|
|
|
exe buf .. "bw!"
|
|
|
|
|
endfunc
|
|
|
|
|
|
2024-08-26 18:45:37 +02:00
|
|
|
func TearDown()
|
|
|
|
|
" That file is created at Test_crash1_3() by dialog_changed_uaf
|
|
|
|
|
" but cleaning up in that test doesn't remove it. Let's try again at
|
2024-08-24 17:34:19 +02:00
|
|
|
" the end of this test script
|
|
|
|
|
call delete('Untitled')
|
|
|
|
|
endfunc
|
|
|
|
|
|
2023-09-02 14:40:13 +02:00
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|