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/gui/folder_select.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/gui/folder_select.c') diff --git a/apps/gui/folder_select.c b/apps/gui/folder_select.c index 50d25e7305..a76d77562b 100644 --- a/apps/gui/folder_select.c +++ b/apps/gui/folder_select.c @@ -185,7 +185,7 @@ static struct folder* load_folder(struct folder* parent, char *folder) if (len >= sizeof(fullpath)) goto fail; } - strlcpy(&fullpath[len], folder, sizeof(fullpath) - len); + strmemccpy(&fullpath[len], folder, sizeof(fullpath) - len); logf("load_folder: [%s]", fullpath); dir = opendir(fullpath); @@ -518,7 +518,7 @@ static int select_paths(struct folder* root, const char* filenames) lastfnp = fnp; if (len <= 0 || len + 1 >= buflen) continue; - strlcpy(buf, sstr, len + 1); + strmemccpy(buf, sstr, len + 1); struct child *item = find_from_filename(buf, root); if (item) item->state = SELECTED; @@ -563,7 +563,7 @@ static void save_folders_r(struct folder *root, char* dst, size_t maxlen, size_t int dlen = strlen(dst); if (dlen + len >= maxlen) continue; - strlcpy(&dst[dlen], buffer_front, maxlen - dlen); + strmemccpy(&dst[dlen], buffer_front, maxlen - dlen); } else { -- cgit v1.2.3