refactor: Remove strncpy/STRNCPY. (#6008)

Closes #731
References #851

Note: This does not remove some intentional legacy usages of strncpy.
      - memcpy isn't equivalent because it doesn't check the string
        length of `src`, and doesn't zero-out the remainder of `dst`.
      - xstrlcpy isn't equivalent because it doesn't zero-out the
        remainder of `dst`. Some Vim logic depends on that (e.g.
        ex_append which calls vim_strnsave).

Helped-by: Douglas Schneider <ds3@ualberta.ca>
Helped-by: oni-link <knil.ino@gmail.com>
Helped-by: James McCoy <jamessan@jamessan.com>
This commit is contained in:
Justin M. Keyes
2017-01-26 14:33:03 +01:00
committed by GitHub
parent f78982620a
commit 59fd0c4132
12 changed files with 53 additions and 51 deletions

View File

@@ -310,7 +310,7 @@ void nvim_set_current_dir(String dir, Error *err)
}
char string[MAXPATHL];
strncpy(string, dir.data, dir.size);
memcpy(string, dir.data, dir.size);
string[dir.size] = NUL;
try_start();