Mercurial > vim
annotate src/testdir/test_cmd_lists.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 | dbec60b8c253 |
children |
rev | line source |
---|---|
30837
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test to verify that the cmd list in runtime/doc/index.txt contains all of |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 " the commands in src/ex_cmds.h. It doesn't map the other way round because |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 " index.txt contains some shorthands like :!! which are useful to list, but |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 " they don't exist as an independent entry in src/ex_cmds.h. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 " |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 " Currently this just checks for existence, and we aren't checking for whether |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 " they are sorted in the index, or whether the substring needed (e.g. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 " 'defc[ompile]') is correct or not. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 func Test_cmd_lists() |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 " Create a list of the commands in ex_cmds.h:CMD_index. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 enew! |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 read ../ex_cmds.h |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 1,/^enum CMD_index$/d |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 call search('^};$') |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 .,$d |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 v/^EXCMD/d |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 %s/^.*"\(\S\+\)".*$/\1/ |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 " Special case ':*' because it's represented as ':star' |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 %s/^\*$/star/ |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 sort u |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 let l:command_list = getline(1, '$') |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 " Verify that the ':help ex-cmd-index' list contains all known commands. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 enew! |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 if filereadable('../../doc/index.txt') |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 " unpacked MS-Windows zip archive |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 read ../../doc/index.txt |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 else |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 read ../../runtime/doc/index.txt |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 endif |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 call search('\*ex-cmd-index\*') |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 1,.d |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 v/^|:/d |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 %s/^|:\(\S*\)|.*/\1/ |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 sort u |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 norm gg |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 let l:missing_cmds = [] |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 for cmd in l:command_list |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 " Reserved Vim 9 commands or other script-only syntax aren't useful to |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 " document as Ex commands. |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 let l:vim9cmds = [ |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 \ 'abstract', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 \ 'class', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 \ 'endclass', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 \ 'endenum', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 \ 'endinterface', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 \ 'enum', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 \ 'interface', |
31337
2ddb98b138b5
patch 9.0.1002: command list test fails
Bram Moolenaar <Bram@vim.org>
parents:
30837
diff
changeset
|
51 \ 'public', |
30837
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 \ 'static', |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
31337
diff
changeset
|
53 \ 'this', |
30837
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 \ 'type', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 \ '++', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 \ '--', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 \ '{', |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 \ '}'] |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 if index(l:vim9cmds, cmd) != -1 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 continue |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 endif |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 if search('^\V' .. cmd .. '\v$', 'cW') == 0 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 call add(l:missing_cmds, ':' .. cmd) |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 endif |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 endfor |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 call assert_equal(0, len(l:missing_cmds), "Missing commands from `:help ex-cmd-index`: " .. string(l:missing_cmds)) |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 endfunc |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
82c3677f8af1
patch 9.0.0753: some Ex commands are not in the help index
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 " vim: shiftwidth=2 sts=2 expandtab |