]> granicus.if.org Git - vim/commitdiff
patch 8.0.0248: vim_strcat() cannot handle overlapping arguments v8.0.0248
authorBram Moolenaar <Bram@vim.org>
Fri, 27 Jan 2017 20:54:07 +0000 (21:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 Jan 2017 20:54:07 +0000 (21:54 +0100)
Problem:    vim_strcat() cannot handle overlapping arguments.
Solution:   Use mch_memmove() instead of strcpy(). (Justin M Keyes,
            closes #1415)

src/misc2.c
src/version.c

index 9c39d40394d8cf82337e385560901157c36b8f33..71ca6d8f5ba6df42fe074b27a0e73c40e591b61a 100644 (file)
@@ -1719,7 +1719,7 @@ vim_strncpy(char_u *to, char_u *from, size_t len)
 
 /*
  * Like strcat(), but make sure the result fits in "tosize" bytes and is
- * always NUL terminated.
+ * always NUL terminated. "from" and "to" may overlap.
  */
     void
 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)
        to[tosize - 1] = NUL;
     }
     else
-       STRCPY(to + tolen, from);
+       mch_memmove(to + tolen, from, fromlen + 1);
 }
 
 /*
index 199c37d5bd1f273aa8af2048f9ddc486f106b0d2..11259921b0e671c9dc7d2bcc835bcf735cbce21e 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    248,
 /**/
     247,
 /**/