summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-06 15:38:21 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-06 15:38:21 +0100
commit44a3f3353e0407e9fffee138125a6927d1c9e7e5 (patch)
tree2f8eab55877ffb8d6b51d8be01aaeeccf71db6e9
parent1f89abf69d2c485c38da9a45161e806de0f86f2f (diff)
downloadvim-git-44a3f3353e0407e9fffee138125a6927d1c9e7e5.tar.gz
patch 8.2.5063: error for a command may go over the end of IObuffv8.2.5063
Problem: Error for a command may go over the end of IObuff. Solution: Truncate the message.
-rw-r--r--src/ex_docmd.c12
-rw-r--r--src/testdir/test_cmdline.vim5
-rw-r--r--src/version.c2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index cfb40e8d5..634a1bcef 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3441,9 +3441,17 @@ theend:
static void
append_command(char_u *cmd)
{
- char_u *s = cmd;
- char_u *d;
+ size_t len = STRLEN(IObuff);
+ char_u *s = cmd;
+ char_u *d;
+ if (len > IOSIZE - 100)
+ {
+ // Not enough space, truncate and put in "...".
+ d = IObuff + IOSIZE - 100;
+ d -= mb_head_off(IObuff, d);
+ STRCPY(d, "...");
+ }
STRCAT(IObuff, ": ");
d = IObuff + STRLEN(IObuff);
while (*s != NUL && d - IObuff + 5 < IOSIZE)
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 77965b3f6..2289c343e 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -3413,4 +3413,9 @@ func Test_recursive_register()
call assert_equal('yes', caught)
endfunc
+func Test_long_error_message()
+ " the error should be truncated, not overrun IObuff
+ silent! norm Q00000000000000     000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000                                                                                                                                                                                                                        
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 542028606..dd585c81a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 5063,
+/**/
5062,
/**/
5061,