Skip to content

Commit

Permalink
patch 8.2.4647: "source" can read past end of copied line
Browse files Browse the repository at this point in the history
Problem:    "source" can read past end of copied line.
Solution:   Add a terminating NUL.
  • Loading branch information
brammool committed Mar 29, 2022
1 parent b55986c commit 2bdad61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/scriptfile.c
Expand Up @@ -1918,7 +1918,10 @@ get_one_sourceline(source_cookie_T *sp)
break; // all the lines are processed
ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);
sp->buf_lnum++;
if (ga_grow(&ga, 1) == FAIL)
break;
buf = (char_u *)ga.ga_data;
buf[ga.ga_len++] = NUL;
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_source.vim
Expand Up @@ -646,4 +646,13 @@ func Test_source_buffer_vim9()
%bw!
endfunc

func Test_source_buffer_long_line()
" This was reading past the end of the line.
new
norm300gr0
so
bwipe!
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4647,
/**/
4646,
/**/
Expand Down

0 comments on commit 2bdad61

Please sign in to comment.