Commit f467c2fc authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Tweak error handling in parse_config_line.

parent 709df665
...@@ -821,7 +821,7 @@ parse_config_line(int c, gnc_t gnc, void *closure) ...@@ -821,7 +821,7 @@ parse_config_line(int c, gnc_t gnc, void *closure)
char *token; char *token;
c = skip_whitespace(c, gnc, closure); c = skip_whitespace(c, gnc, closure);
if(c == '\n' || c == '#') if(c < 0 || c == '\n' || c == '#')
return skip_to_eol(c, gnc, closure); return skip_to_eol(c, gnc, closure);
c = getword(c, &token, gnc, closure); c = getword(c, &token, gnc, closure);
...@@ -832,36 +832,36 @@ parse_config_line(int c, gnc_t gnc, void *closure) ...@@ -832,36 +832,36 @@ parse_config_line(int c, gnc_t gnc, void *closure)
struct filter *filter; struct filter *filter;
c = parse_filter(c, gnc, closure, &filter); c = parse_filter(c, gnc, closure, &filter);
if(c < -1) if(c < -1)
return -1; goto fail;
add_filter(filter, &input_filters); add_filter(filter, &input_filters);
} else if(strcmp(token, "out") == 0) { } else if(strcmp(token, "out") == 0) {
struct filter *filter; struct filter *filter;
c = parse_filter(c, gnc, closure, &filter); c = parse_filter(c, gnc, closure, &filter);
if(c < -1) if(c < -1)
return -1; goto fail;
add_filter(filter, &output_filters); add_filter(filter, &output_filters);
} else if(strcmp(token, "redistribute") == 0) { } else if(strcmp(token, "redistribute") == 0) {
struct filter *filter; struct filter *filter;
c = parse_filter(c, gnc, closure, &filter); c = parse_filter(c, gnc, closure, &filter);
if(c < -1) if(c < -1)
return -1; goto fail;
add_filter(filter, &redistribute_filters); add_filter(filter, &redistribute_filters);
} else if(strcmp(token, "install") == 0) { } else if(strcmp(token, "install") == 0) {
struct filter *filter; struct filter *filter;
c = parse_filter(c, gnc, closure, &filter); c = parse_filter(c, gnc, closure, &filter);
if(c < -1) if(c < -1)
return -1; goto fail;
} else if(strcmp(token, "interface") == 0) { } else if(strcmp(token, "interface") == 0) {
struct interface_conf *if_conf; struct interface_conf *if_conf;
c = parse_ifconf(c, gnc, closure, &if_conf); c = parse_ifconf(c, gnc, closure, &if_conf);
if(c < -1) if(c < -1)
return -1; goto fail;
add_ifconf(if_conf, &interface_confs); add_ifconf(if_conf, &interface_confs);
} else if(strcmp(token, "default") == 0) { } else if(strcmp(token, "default") == 0) {
struct interface_conf *if_conf; struct interface_conf *if_conf;
c = parse_anonymous_ifconf(c, gnc, closure, NULL, &if_conf); c = parse_anonymous_ifconf(c, gnc, closure, NULL, &if_conf);
if(c < -1) if(c < -1)
return -1; goto fail;
if(default_interface_conf == NULL) if(default_interface_conf == NULL)
default_interface_conf = if_conf; default_interface_conf = if_conf;
else { else {
...@@ -872,10 +872,14 @@ parse_config_line(int c, gnc_t gnc, void *closure) ...@@ -872,10 +872,14 @@ parse_config_line(int c, gnc_t gnc, void *closure)
} else { } else {
c = parse_option(c, gnc, closure, token); c = parse_option(c, gnc, closure, token);
if(c < -1) if(c < -1)
return -1; goto fail;
} }
free(token); free(token);
return c; return c;
fail:
free(token);
return -2;
} }
struct file_state { struct file_state {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment