forked from aniani/vim
updated for version 7.3.160
Problem: Unsafe string copying. Solution: Use vim_strncpy() instead of strcpy(). Use vim_strcat() instead of strcat().
This commit is contained in:
22
src/misc2.c
22
src/misc2.c
@@ -1646,6 +1646,28 @@ vim_strncpy(to, from, len)
|
||||
to[len] = NUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like strcat(), but make sure the result fits in "tosize" bytes and is
|
||||
* always NUL terminated.
|
||||
*/
|
||||
void
|
||||
vim_strcat(to, from, tosize)
|
||||
char_u *to;
|
||||
char_u *from;
|
||||
size_t tosize;
|
||||
{
|
||||
size_t tolen = STRLEN(to);
|
||||
size_t fromlen = STRLEN(from);
|
||||
|
||||
if (tolen + fromlen + 1 > tosize)
|
||||
{
|
||||
mch_memmove(to + tolen, from, tosize - tolen - 1);
|
||||
to[tosize - 1] = NUL;
|
||||
}
|
||||
else
|
||||
STRCPY(to + tolen, from);
|
||||
}
|
||||
|
||||
/*
|
||||
* Isolate one part of a string option where parts are separated with
|
||||
* "sep_chars".
|
||||
|
Reference in New Issue
Block a user