Mercurial > vim
annotate src/testdir/test_preview.vim @ 33863:3b8089d550eb v9.0.2141
patch 9.0.2141: [security]: buffer-overflow in suggest_trie_walk
Commit: https://github.com/vim/vim/commit/0fb375aae608d7306b4baf9c1f906961f32e2abf
Author: Christian Brabandt <cb@256bit.org>
Date: Wed Nov 29 10:23:39 2023 +0100
patch 9.0.2141: [security]: buffer-overflow in suggest_trie_walk
Problem: [security]: buffer-overflow in suggest_trie_walk
Solution: Check n before using it as index into byts array
Basically, n as an index into the byts array, can point to beyond the byts
array. So let's double check, that n is within the expected range after
incrementing it from sp->ts_curi and bail out if it would be invalid.
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:03 +0100 |
parents | 457ea0570b6f |
children |
rev | line source |
---|---|
11759
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for the preview window |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20879
diff
changeset
|
2 |
18767
068337e86133
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents:
11759
diff
changeset
|
3 source check.vim |
068337e86133
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents:
11759
diff
changeset
|
4 CheckFeature quickfix |
11759
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 func Test_Psearch() |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " this used to cause ml_get errors |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 help |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 let wincount = winnr('$') |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 0f |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 ps. |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_equal(wincount + 1, winnr('$')) |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 pclose |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal(wincount, winnr('$')) |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 bwipe |
5e36b2f825cb
patch 8.0.0762: ml_get error with :psearch in buffer without a name
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfunc |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
17 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
18 func Test_window_preview() |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
19 CheckFeature quickfix |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
20 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
21 " Open a preview window |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
22 pedit Xa |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
23 call assert_equal(2, winnr('$')) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
24 call assert_equal(0, &previewwindow) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
25 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
26 " Go to the preview window |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
27 wincmd P |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
28 call assert_equal(1, &previewwindow) |
20879
0ab45b558621
patch 8.2.0991: cannot get window type for autocmd and preview window
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
29 call assert_equal('preview', win_gettype()) |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
30 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
31 " Close preview window |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
32 wincmd z |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
33 call assert_equal(1, winnr('$')) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
34 call assert_equal(0, &previewwindow) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
35 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
36 call assert_fails('wincmd P', 'E441:') |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
37 endfunc |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
38 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
39 func Test_window_preview_from_help() |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
40 CheckFeature quickfix |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
41 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
42 filetype on |
30592
457ea0570b6f
patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
43 call writefile(['/* some C code */'], 'Xpreview.c', 'D') |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
44 help |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
45 pedit Xpreview.c |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
46 wincmd P |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
47 call assert_equal(1, &previewwindow) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
48 call assert_equal('c', &filetype) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
49 wincmd z |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
50 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
51 filetype off |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
52 close |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
53 endfunc |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
54 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
55 func Test_multiple_preview_windows() |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
56 new |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
57 set previewwindow |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
58 new |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
59 call assert_fails('set previewwindow', 'E590:') |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
60 %bw! |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
61 endfunc |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
62 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
63 " vim: shiftwidth=2 sts=2 expandtab |