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 --- firmware/common/dircache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'firmware/common/dircache.c') diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 1d6371a6b5..5902f8b3fd 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -1707,8 +1707,8 @@ static int sab_process_dir(struct dircache_entry *ce) /* save current paths size */ int pathpos = strlen(sab_path); /* append entry */ - strlcpy(&sab_path[pathpos], "/", sizeof(sab_path) - pathpos); - strlcpy(&sab_path[pathpos+1], entry->d_name, sizeof(sab_path) - pathpos - 1); + strmemccpy(&sab_path[pathpos], "/", sizeof(sab_path) - pathpos); + strmemccpy(&sab_path[pathpos+1], entry->d_name, sizeof(sab_path) - pathpos - 1); int rc = sab_process_dir(ce->down); /* restore path */ @@ -1735,7 +1735,7 @@ static int sab_process_dir(struct dircache_entry *ce) static int sab_process_volume(IF_MV(int volume,) struct dircache_entry *ce) { memset(ce, 0, sizeof(struct dircache_entry)); - strlcpy(sab_path, "/", sizeof sab_path); + strmemccpy(sab_path, "/", sizeof sab_path); return sab_process_dir(ce); } @@ -1755,7 +1755,7 @@ int dircache_readdir_r(struct dircache_dirscan *dir, struct DIRENT *result) dir->scanidx = ce - dircache_root; - strlcpy(result->d_name, ce->d_name, sizeof (result->d_name)); + strmemccpy(result->d_name, ce->d_name, sizeof (result->d_name)); result->info = ce->dirinfo; return 1; -- cgit v1.2.3