diff options
author | cztchoice <cztchoice@gmail.com> | 2015-07-18 17:27:05 +0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-23 15:49:36 +0100 |
commit | 6e75bb5cbbf172bf586b3326ac43bad219ae26a3 (patch) | |
tree | 8469ad21d44fa6afa16c95a0a5504dd4bfbf66d0 /src/nvim/path.c | |
parent | d4b931deacf61528e902623d38d0f4d314bc1839 (diff) | |
download | rneovim-6e75bb5cbbf172bf586b3326ac43bad219ae26a3.tar.gz rneovim-6e75bb5cbbf172bf586b3326ac43bad219ae26a3.tar.bz2 rneovim-6e75bb5cbbf172bf586b3326ac43bad219ae26a3.zip |
refactor: strlcat instead of str{n}cat.
Add xstrlcat function.
Closes #3042
References #988
References #1069
coverity: 71530, 71531, 71532
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r-- | src/nvim/path.c | 8 |
1 files changed, 6 insertions, 2 deletions
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. |