Confparse: Fix possibly segfault if there is many option on a single line and if there is a missing '='.
This commit is contained in:
parent
6715ba034b
commit
77ead81d3f
13
src/config.c
13
src/config.c
@ -301,21 +301,20 @@ conf_layout_section(char *src)
|
||||
{
|
||||
tmp = get_nsec(src, "layout", i);
|
||||
|
||||
if(!name_to_func(get_opt(tmp, "", "type").str, layout_list))
|
||||
if(!name_to_func(get_opt(tmp, "tile", "type").str, layout_list))
|
||||
{
|
||||
fprintf(stderr, "WMFS Configuration: Unknow Layout type: \"%s\"\n",
|
||||
get_opt(tmp, "", "type").str);
|
||||
/* exit(EXIT_FAILURE); */
|
||||
get_opt(tmp, "tile", "type").str);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(conf.layout_system && conf.nlayout > 1)
|
||||
menu_new_item(&menulayout.item[i], get_opt(tmp, "", "symbol").str,
|
||||
uicb_set_layout,
|
||||
get_opt(tmp, "", "type").str);
|
||||
get_opt(tmp, "tile", "type").str);
|
||||
|
||||
conf.layout[i].symbol = get_opt(tmp, "", "symbol").str;
|
||||
conf.layout[i].func = name_to_func(get_opt(tmp, "", "type").str, layout_list);
|
||||
conf.layout[i].symbol = get_opt(tmp, "TILE (default)", "symbol").str;
|
||||
conf.layout[i].func = name_to_func(get_opt(tmp, "tile", "type").str, layout_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -507,8 +506,8 @@ conf_keybind_section(char *src)
|
||||
fprintf(stderr, "WMFS Configuration warning: Unknow Function \"%s\"\n", get_opt(tmp, "", "func").str);
|
||||
keys[i].func = uicb_spawn;
|
||||
}
|
||||
keys[i].cmd = (!get_opt(tmp, "", "cmd").str) ? NULL : get_opt(tmp, "", "cmd").str;
|
||||
|
||||
keys[i].cmd = (!get_opt(tmp, "", "cmd").str) ? NULL : get_opt(tmp, "", "cmd").str;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -152,7 +152,7 @@ opt_type
|
||||
get_opt(char *src, char *def, char *name)
|
||||
{
|
||||
int i;
|
||||
char *p = NULL;
|
||||
char *p = NULL, *p2 = NULL;
|
||||
opt_type ret = null_opt_type;
|
||||
|
||||
if(!src || !name)
|
||||
@ -163,8 +163,21 @@ get_opt(char *src, char *def, char *name)
|
||||
for(i = 0; p[i] && p[i] != '\n'; ++i);
|
||||
p[i] = '\0';
|
||||
|
||||
p2 = _strdup(p + strlen(name));
|
||||
|
||||
if((p = strchr(p, '=')) && !is_in_delimiter(p, 0))
|
||||
{
|
||||
for(i = 0; p2[i] && p2[i] != '='; ++i);
|
||||
p2[i] = '\0';
|
||||
|
||||
/* Check if there is anything else that spaces
|
||||
* between option name and '=' */
|
||||
for(i = 0; i < strlen(p2); ++i)
|
||||
if(p2[i] != ' ')
|
||||
return str_to_opt(def);
|
||||
|
||||
ret = str_to_opt(clean_value(++p));
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = str_to_opt(def);
|
||||
@ -214,7 +227,7 @@ get_list_opt(char *src, char *def, char *name, int *n)
|
||||
/* Set all value in return array */
|
||||
for(i = j = 0; i < *n; ++i, p2 += ++j)
|
||||
{
|
||||
for(j = 0; j < strlen(p2) && (p2[j] != ',' || is_in_delimiter(p2, j)); j++);
|
||||
for(j = 0; j < strlen(p2) && (p2[j] != ',' || is_in_delimiter(p2, j)); ++j);
|
||||
p2[j] = '\0';
|
||||
|
||||
ret[i] = str_to_opt(clean_value(p2));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user