Skip to content

Commit 45600ce

Browse files
committed
patch 8.0.0248: vim_strcat() cannot handle overlapping arguments
Problem: vim_strcat() cannot handle overlapping arguments. Solution: Use mch_memmove() instead of strcpy(). (Justin M Keyes, closes #1415)
1 parent aed6d0b commit 45600ce

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/misc2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ vim_strncpy(char_u *to, char_u *from, size_t len)
17191719

17201720
/*
17211721
* Like strcat(), but make sure the result fits in "tosize" bytes and is
1722-
* always NUL terminated.
1722+
* always NUL terminated. "from" and "to" may overlap.
17231723
*/
17241724
void
17251725
vim_strcat(char_u *to, char_u *from, size_t tosize)
@@ -1733,7 +1733,7 @@ vim_strcat(char_u *to, char_u *from, size_t tosize)
17331733
to[tosize - 1] = NUL;
17341734
}
17351735
else
1736-
STRCPY(to + tolen, from);
1736+
mch_memmove(to + tolen, from, fromlen + 1);
17371737
}
17381738

17391739
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
248,
767769
/**/
768770
247,
769771
/**/

0 commit comments

Comments
 (0)