1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Aidan MacDonald 2021-11-28 14:36:49 +00:00
parent 31242f8570
commit c086a3386f

View file

@ -37,6 +37,18 @@ static int xdigit_to_int(char c)
return -1;
}
static int isfilenamechar(char c)
{
return (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
c == '$' || c == '%' || c == '\'' || c == '-' || c == '_' ||
c == '@' || c == '~' || c == '`' || c == '!' || c == '(' ||
c == ')' || c == '{' || c == '}' || c == '^' || c == '#' ||
c == '&' || c == '+' || c == ',' || c == ';' || c == '=' ||
c == '[' || c == ']' || c == '.';
}
int xf_map_parseline(const char* line, struct xf_map* map)
{
enum {
@ -66,7 +78,7 @@ int xf_map_parseline(const char* line, struct xf_map* map)
if(*line == ' ' || *line == '\t') {
nextstate();
continue;
} else if(isgraph((unsigned char)*line)) {
} else if(isfilenamechar(*line)) {
if(length == XF_MAP_NAMELEN)
return XF_E_FILENAME_TOO_LONG;