refactor: strlcat instead of str{n}cat.

Add xstrlcat function.

Closes #3042
References #988
References #1069

coverity: 71530, 71531, 71532
This commit is contained in:
cztchoice
2015-07-18 17:27:05 +08:00
committed by Justin M. Keyes
parent d4b931deac
commit 6e75bb5cbb
7 changed files with 52 additions and 11 deletions

View File

@@ -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.