Package: vim / 2:8.0.0197-4+deb9u1

upstream/patch-8.0.0703-illegal-memory-access-with-empty-doau-comm.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From: Bram Moolenaar <Bram@vim.org>
Date: Sun, 9 Jul 2017 11:07:16 +0200
Subject: patch 8.0.0703: illegal memory access with empty :doau command

Problem:    Illegal memory access with empty :doau command.
Solution:   Check the event for being out of range. (James McCoy)
---
 src/fileio.c                 | 7 ++++---
 src/testdir/test_autocmd.vim | 4 ++++
 src/version.c                | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index aeb53b5..d305c82 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -8790,7 +8790,7 @@ do_doautocmd(
     /*
      * Loop over the events.
      */
-    while (*arg && !vim_iswhite(*arg))
+    while (*arg && !ends_excmd(*arg) && !vim_iswhite(*arg))
 	if (apply_autocmds_group(event_name2nr(arg, &arg),
 				      fname, NULL, TRUE, group, curbuf, NULL))
 	    nothing_done = FALSE;
@@ -9306,7 +9306,8 @@ apply_autocmds_group(
      * Quickly return if there are no autocommands for this event or
      * autocommands are blocked.
      */
-    if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
+    if (event == NUM_EVENTS || first_autopat[(int)event] == NULL
+	    || autocmd_blocked > 0)
 	goto BYPASS_AU;
 
     /*
@@ -9379,7 +9380,7 @@ apply_autocmds_group(
     {
 	if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)
 	    autocmd_fname = NULL;
-	else if (fname != NULL && *fname != NUL)
+	else if (fname != NULL && !ends_excmd(*fname))
 	    autocmd_fname = fname;
 	else if (buf != NULL)
 	    autocmd_fname = buf->b_ffname;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 566a07c..2a783f4 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -341,3 +341,7 @@ func Test_BufEnter()
   call delete('Xdir', 'd')
   au! BufEnter
 endfunc
+
+func Test_empty_doau()
+  doau \|
+endfunc
diff --git a/src/version.c b/src/version.c
index b10438e..6781ef2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -771,6 +771,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    703,
+/**/
     550,
 /**/
     378,