summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-11-28 14:36:49 +0000
committerAidan MacDonald <amachronic@protonmail.com>2021-11-28 15:46:06 +0000
commitc086a3386f844e9e62df8fde22d27459dd66d541 (patch)
treee9cbb249074658187d66016cf930b88ee0dedddd
parent31242f8570c870f60feecb6a5039d19863ecdc55 (diff)
downloadrockbox-c086a3386f844e9e62df8fde22d27459dd66d541.tar.gz
rockbox-c086a3386f844e9e62df8fde22d27459dd66d541.zip
x1000-installer: map filenames accept only valid characters
Instead of using isgraph(), check for legal FAT32 characters excluding spaces (which are used as field separators). Change-Id: I291f0acb5f24c558099c237d913f4f35ae06b834
-rw-r--r--lib/x1000-installer/src/xf_flashmap.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/x1000-installer/src/xf_flashmap.c b/lib/x1000-installer/src/xf_flashmap.c
index 2cde0f1c20..dc0a26a019 100644
--- a/lib/x1000-installer/src/xf_flashmap.c
+++ b/lib/x1000-installer/src/xf_flashmap.c
@@ -37,6 +37,18 @@ static int xdigit_to_int(char c)
37 return -1; 37 return -1;
38} 38}
39 39
40static int isfilenamechar(char c)
41{
42 return (c >= 'a' && c <= 'z') ||
43 (c >= 'A' && c <= 'Z') ||
44 (c >= '0' && c <= '9') ||
45 c == '$' || c == '%' || c == '\'' || c == '-' || c == '_' ||
46 c == '@' || c == '~' || c == '`' || c == '!' || c == '(' ||
47 c == ')' || c == '{' || c == '}' || c == '^' || c == '#' ||
48 c == '&' || c == '+' || c == ',' || c == ';' || c == '=' ||
49 c == '[' || c == ']' || c == '.';
50}
51
40int xf_map_parseline(const char* line, struct xf_map* map) 52int xf_map_parseline(const char* line, struct xf_map* map)
41{ 53{
42 enum { 54 enum {
@@ -66,7 +78,7 @@ int xf_map_parseline(const char* line, struct xf_map* map)
66 if(*line == ' ' || *line == '\t') { 78 if(*line == ' ' || *line == '\t') {
67 nextstate(); 79 nextstate();
68 continue; 80 continue;
69 } else if(isgraph((unsigned char)*line)) { 81 } else if(isfilenamechar(*line)) {
70 if(length == XF_MAP_NAMELEN) 82 if(length == XF_MAP_NAMELEN)
71 return XF_E_FILENAME_TOO_LONG; 83 return XF_E_FILENAME_TOO_LONG;
72 84