summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-14 11:32:34 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2022-11-14 23:56:16 -0500
commitf6c719d7ec71cc7771c46d3daa390924a3871ba3 (patch)
treee6209f23565db01809f75067247e667963092ff6 /apps/gui
parentb25a9d8f99b75570d18ea64602de7fe48da612d6 (diff)
downloadrockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.tar.gz
rockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.zip
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
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/folder_select.c6
-rw-r--r--apps/gui/option_select.c8
-rw-r--r--apps/gui/skin_engine/skin_backdrops.c2
-rw-r--r--apps/gui/skin_engine/skin_parser.c2
-rw-r--r--apps/gui/skin_engine/skin_tokens.c2
-rw-r--r--apps/gui/statusbar-skinned.c1
6 files changed, 10 insertions, 11 deletions
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)
185 if (len >= sizeof(fullpath)) 185 if (len >= sizeof(fullpath))
186 goto fail; 186 goto fail;
187 } 187 }
188 strlcpy(&fullpath[len], folder, sizeof(fullpath) - len); 188 strmemccpy(&fullpath[len], folder, sizeof(fullpath) - len);
189 logf("load_folder: [%s]", fullpath); 189 logf("load_folder: [%s]", fullpath);
190 190
191 dir = opendir(fullpath); 191 dir = opendir(fullpath);
@@ -518,7 +518,7 @@ static int select_paths(struct folder* root, const char* filenames)
518 lastfnp = fnp; 518 lastfnp = fnp;
519 if (len <= 0 || len + 1 >= buflen) 519 if (len <= 0 || len + 1 >= buflen)
520 continue; 520 continue;
521 strlcpy(buf, sstr, len + 1); 521 strmemccpy(buf, sstr, len + 1);
522 struct child *item = find_from_filename(buf, root); 522 struct child *item = find_from_filename(buf, root);
523 if (item) 523 if (item)
524 item->state = SELECTED; 524 item->state = SELECTED;
@@ -563,7 +563,7 @@ static void save_folders_r(struct folder *root, char* dst, size_t maxlen, size_t
563 int dlen = strlen(dst); 563 int dlen = strlen(dst);
564 if (dlen + len >= maxlen) 564 if (dlen + len >= maxlen)
565 continue; 565 continue;
566 strlcpy(&dst[dlen], buffer_front, maxlen - dlen); 566 strmemccpy(&dst[dlen], buffer_front, maxlen - dlen);
567 } 567 }
568 else 568 else
569 { 569 {
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index e154467428..4687367fba 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -68,8 +68,8 @@ const char *option_get_valuestring(const struct settings_list *setting,
68 if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) 68 if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING)
69 { 69 {
70 bool val = (bool)temp_var; 70 bool val = (bool)temp_var;
71 strlcpy(buffer, str(val? setting->bool_setting->lang_yes : 71 strmemccpy(buffer, str(val? setting->bool_setting->lang_yes :
72 setting->bool_setting->lang_no), buf_len); 72 setting->bool_setting->lang_no), buf_len);
73 } 73 }
74#if 0 /* probably dont need this one */ 74#if 0 /* probably dont need this one */
75 else if ((setting->flags & F_FILENAME) == F_FILENAME) 75 else if ((setting->flags & F_FILENAME) == F_FILENAME)
@@ -121,7 +121,7 @@ const char *option_get_valuestring(const struct settings_list *setting,
121 const struct choice_setting *info = setting->choice_setting; 121 const struct choice_setting *info = setting->choice_setting;
122 if (info->talks[(int)temp_var] < LANG_LAST_INDEX_IN_ARRAY) 122 if (info->talks[(int)temp_var] < LANG_LAST_INDEX_IN_ARRAY)
123 { 123 {
124 strlcpy(buffer, str(info->talks[(int)temp_var]), buf_len); 124 strmemccpy(buffer, str(info->talks[(int)temp_var]), buf_len);
125 } 125 }
126 else 126 else
127 { 127 {
@@ -133,7 +133,7 @@ const char *option_get_valuestring(const struct settings_list *setting,
133 { 133 {
134 int value = (int)temp_var; 134 int value = (int)temp_var;
135 char *val = P2STR(setting->choice_setting->desc[value]); 135 char *val = P2STR(setting->choice_setting->desc[value]);
136 strlcpy(buffer, val, buf_len); 136 strmemccpy(buffer, val, buf_len);
137 } 137 }
138 } 138 }
139 return str; 139 return str;
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c
index 215667d585..8be40d1ce2 100644
--- a/apps/gui/skin_engine/skin_backdrops.c
+++ b/apps/gui/skin_engine/skin_backdrops.c
@@ -137,7 +137,7 @@ int skin_backdrop_assign(char* backdrop, char *bmpdir,
137 } 137 }
138 if (free >= 0) 138 if (free >= 0)
139 { 139 {
140 strlcpy(backdrops[free].name, filename, MAX_PATH); 140 strmemccpy(backdrops[free].name, filename, MAX_PATH);
141 backdrops[free].buffer = NULL; 141 backdrops[free].buffer = NULL;
142 backdrops[free].screen = screen; 142 backdrops[free].screen = screen;
143 backdrops[free].ref_count = 1; 143 backdrops[free].ref_count = 1;
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 419e49810d..4e3b7e4d12 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -2548,7 +2548,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2548 { 2548 {
2549 /* get the bitmap dir */ 2549 /* get the bitmap dir */
2550 char *dot = strrchr(buf, '.'); 2550 char *dot = strrchr(buf, '.');
2551 strlcpy(bmpdir, buf, dot - buf + 1); 2551 strmemccpy(bmpdir, buf, dot - buf + 1);
2552 } 2552 }
2553 else 2553 else
2554 { 2554 {
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index a1d0a4b840..6d9d489a17 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -114,7 +114,7 @@ char* get_dir(char* buf, int buf_size, const char* path, int level)
114 return NULL; 114 return NULL;
115 115
116 len = MIN(last_sep - sep, buf_size - 1); 116 len = MIN(last_sep - sep, buf_size - 1);
117 strlcpy(buf, sep + 1, len + 1); 117 strmemccpy(buf, sep + 1, len + 1);
118 return buf; 118 return buf;
119} 119}
120 120
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 5d2b65846d..d6dddf5cd2 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -27,7 +27,6 @@
27#include "appevents.h" 27#include "appevents.h"
28#include "screens.h" 28#include "screens.h"
29#include "screen_access.h" 29#include "screen_access.h"
30#include "strlcpy.h"
31#include "skin_parser.h" 30#include "skin_parser.h"
32#include "skin_buffer.h" 31#include "skin_buffer.h"
33#include "skin_engine/skin_engine.h" 32#include "skin_engine/skin_engine.h"