Skip to content

Commit

Permalink
patch 8.0.0398: illegal memory access with "t"
Browse files Browse the repository at this point in the history
Problem:    Illegal memory access with "t".
Solution:   Use strncmp() instead of memcmp(). (Dominique Pelle, closes #1528)
  • Loading branch information
brammool committed Mar 1, 2017
1 parent 5a66dfb commit 66727e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/search.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1693,12 +1693,9 @@ searchc(cmdarg_T *cap, int t_cmd)
if (p[col] == c && stop) if (p[col] == c && stop)
break; break;
} }
else else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0
{
if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0
&& stop) && stop)
break; break;
}
stop = TRUE; stop = TRUE;
} }
} }
Expand Down
7 changes: 7 additions & 0 deletions src/testdir/test_search.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -294,3 +294,10 @@ func Test_searchpair()
q! q!
endfunc endfunc


func Test_searchc()
" These commands used to cause memory overflow in searchc().
new
norm ixx
exe "norm 0t\u93cf"
bw!
endfunc
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ static char *(features[]) =


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

0 comments on commit 66727e1

Please sign in to comment.