From f6c719d7ec71cc7771c46d3daa390924a3871ba3 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 14 Nov 2022 11:32:34 -0500 Subject: replace strlcpy with strmemccpy replace applicable calls to strlcpy with calls to strmemccpy which null terminates on truncation in theory the strmemccpy calls should be slightly faster since they don't traverse the rest of the source string on truncation but I seriously doubt there is too much of that going on in the code base Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2 --- apps/tagcache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/tagcache.c') diff --git a/apps/tagcache.c b/apps/tagcache.c index c5c40b9d50..a6c4c875be 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -853,7 +853,7 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,) { struct tagfile_entry *ep = (struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek]; - strlcpy(buf, ep->tag_data, bufsz); + strmemccpy(buf, ep->tag_data, bufsz); return true; } @@ -3469,7 +3469,7 @@ static bool write_tag(int fd, const char *tagstr, const char *datastr) } str_setlen(buf, bufsz - 1); - strlcpy(&buf[i], "\" ", (bufsz - i - 1)); + strmemccpy(&buf[i], "\" ", (bufsz - i - 1)); write(fd, buf, i + 2); @@ -4737,7 +4737,7 @@ void do_tagcache_build(const char *path[]) /* check_dir might add new roots */ for(this = &roots_ll[0]; this; this = this->next) { - strlcpy(curpath, this->path, sizeof(curpath)); + strmemccpy(curpath, this->path, sizeof(curpath)); ret = ret && check_dir(this->path, true); } free_search_roots(&roots_ll[0]); @@ -4792,7 +4792,7 @@ void tagcache_build(void) { char *vect[MAX_STATIC_ROOTS + 1]; /* +1 to ensure NULL sentinel */ char str[sizeof(global_settings.tagcache_scan_paths)]; - strlcpy(str, global_settings.tagcache_scan_paths, sizeof(str)); + strmemccpy(str, global_settings.tagcache_scan_paths, sizeof(str)); int res = split_string(str, ':', vect, MAX_STATIC_ROOTS); vect[res] = NULL; -- cgit v1.2.3