Patch 8.2.5063

9 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 6, 2022, 10:39:02 AM6/6/22
to vim...@googlegroups.com

Patch 8.2.5063
Problem: Error for a command may go over the end of IObuff.
Solution: Truncate the message.
Files: src/ex_docmd.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.5062/src/ex_docmd.c 2022-05-28 14:25:32.127084455 +0100
--- src/ex_docmd.c 2022-06-06 15:35:30.795751057 +0100
***************
*** 3441,3449 ****
static void
append_command(char_u *cmd)
{
! char_u *s = cmd;
! char_u *d;

STRCAT(IObuff, ": ");
d = IObuff + STRLEN(IObuff);
while (*s != NUL && d - IObuff + 5 < IOSIZE)
--- 3441,3457 ----
static void
append_command(char_u *cmd)
{
! 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)
*** ../vim-8.2.5062/src/testdir/test_cmdline.vim 2022-06-01 12:31:05.194803595 +0100
--- src/testdir/test_cmdline.vim 2022-06-06 15:35:07.791776771 +0100
***************
*** 3413,3416 ****
--- 3413,3421 ----
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
*** ../vim-8.2.5062/src/version.c 2022-06-06 10:06:57.807633769 +0100
--- src/version.c 2022-06-06 15:22:46.228653016 +0100
***************
*** 736,737 ****
--- 736,739 ----
{ /* Add new patch number below this line */
+ /**/
+ 5063,
/**/

--
Q: What do you call a fish without an eye?
A: fsh!
Q: What do you call a deer with no eyes?
A: no eye deer.
Q: What do you call a deer with no eyes and no legs?
A: still no eye deer.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages