• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisãof3f45218f923e791fa8e35e7c9040fa925c4a986 (tree)
Hora2022-05-18 04:15:03
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Mensagem de Log

patch 8.2.4975: recursive command line loop may cause a crash

Commit: https://github.com/vim/vim/commit/51f0bfb88a3554ca2dde777d78a59880d1ee37a8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 17 20:11:02 2022 +0100

patch 8.2.4975: recursive command line loop may cause a crash
Problem: Recursive command line loop may cause a crash.
Solution: Limit recursion of getcmdline().

Mudança Sumário

Diff

diff -r 02398ff5b522 -r f3f45218f923 src/ex_getln.c
--- a/src/ex_getln.c Tue May 17 19:00:04 2022 +0200
+++ b/src/ex_getln.c Tue May 17 21:15:03 2022 +0200
@@ -1581,6 +1581,7 @@
15811581 int indent, // indent for inside conditionals
15821582 int clear_ccline) // clear ccline first
15831583 {
1584+ static int depth = 0; // call depth
15841585 int c;
15851586 int i;
15861587 int j;
@@ -1611,6 +1612,9 @@
16111612 int cmdline_type;
16121613 int wild_type;
16131614
1615+ // one recursion level deeper
1616+ ++depth;
1617+
16141618 if (ccline.cmdbuff != NULL)
16151619 {
16161620 // Being called recursively. Since ccline is global, we need to save
@@ -1641,6 +1645,13 @@
16411645 if (init_ccline(firstc, indent) != OK)
16421646 goto theend; // out of memory
16431647
1648+ if (depth == 50)
1649+ {
1650+ // Somehow got into a loop recursively calling getcmdline(), bail out.
1651+ emsg(_(e_command_too_recursive));
1652+ goto theend;
1653+ }
1654+
16441655 ExpandInit(&xpc);
16451656 ccline.xpc = &xpc;
16461657
@@ -2576,6 +2587,7 @@
25762587 {
25772588 char_u *p = ccline.cmdbuff;
25782589
2590+ --depth;
25792591 if (did_save_ccline)
25802592 restore_cmdline(&save_ccline);
25812593 else
diff -r 02398ff5b522 -r f3f45218f923 src/testdir/test_cmdline.vim
--- a/src/testdir/test_cmdline.vim Tue May 17 19:00:04 2022 +0200
+++ b/src/testdir/test_cmdline.vim Tue May 17 21:15:03 2022 +0200
@@ -3392,4 +3392,16 @@
33923392 call feedkeys(":let a\<C-R>=Check_completion()\<CR>\<Esc>", "xt")
33933393 endfunc
33943394
3395+func Test_recursive_register()
3396+ let @= = ''
3397+ silent! ?e/
3398+ let caught = 'no'
3399+ try
3400+ normal //
3401+ catch /E169:/
3402+ let caught = 'yes'
3403+ endtry
3404+ call assert_equal('yes', caught)
3405+endfunc
3406+
33953407 " vim: shiftwidth=2 sts=2 expandtab
diff -r 02398ff5b522 -r f3f45218f923 src/version.c
--- a/src/version.c Tue May 17 19:00:04 2022 +0200
+++ b/src/version.c Tue May 17 21:15:03 2022 +0200
@@ -747,6 +747,8 @@
747747 static int included_patches[] =
748748 { /* Add new patch number below this line */
749749 /**/
750+ 4975,
751+/**/
750752 4974,
751753 /**/
752754 4973,
Show on old repository browser