From 6e75bb5cbbf172bf586b3326ac43bad219ae26a3 Mon Sep 17 00:00:00 2001 From: cztchoice Date: Sat, 18 Jul 2015 17:27:05 +0800 Subject: refactor: strlcat instead of str{n}cat. Add xstrlcat function. Closes #3042 References #988 References #1069 coverity: 71530, 71531, 71532 --- src/nvim/path.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/path.c') diff --git a/src/nvim/path.c b/src/nvim/path.c index 3d1def8dd4..cdb16dbef1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -398,8 +398,12 @@ char *concat_fnames_realloc(char *fname1, const char *fname2, bool sep) void add_pathsep(char *p) FUNC_ATTR_NONNULL_ALL { - if (*p != NUL && !after_pathsep(p, p + strlen(p))) - strcat(p, PATHSEPSTR); + const size_t len = strlen(p); + const size_t pathsep_len = sizeof(PATHSEPSTR); + assert(len < MAXPATHL - pathsep_len); + if (*p != NUL && !after_pathsep(p, p + len)) { + memcpy(p + len, PATHSEPSTR, pathsep_len); + } } /// Get an allocated copy of the full path to a file. -- cgit