If configuration file contains closing brace before opening brace at top level, configuration parsing is stopped and file is not completely parsed. Solution is to detect extra closing brace and display error. Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> --- exec/coroparse.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/exec/coroparse.c b/exec/coroparse.c index 49242f9..14cb61e 100644 --- a/exec/coroparse.c +++ b/exec/coroparse.c @@ -225,6 +225,7 @@ static char *remove_whitespace(char *string, int remove_colon_and_brace) static int parse_section(FILE *fp, char *path, const char **error_string, + int depth, parser_cb_f parser_cb, void *user_data) { @@ -289,7 +290,7 @@ static int parse_section(FILE *fp, return -1; } - if (parse_section(fp, new_keyname, error_string, parser_cb, user_data)) + if (parse_section(fp, new_keyname, error_string, depth + 1, parser_cb, user_data)) return -1; continue ; @@ -318,6 +319,12 @@ static int parse_section(FILE *fp, } if (strchr_rs (line, '}')) { + if (depth == 0) { + *error_string = "parser error: Unexpected closing brace"; + + return -1; + } + if (!parser_cb(path, NULL, NULL, PARSER_CB_SECTION_END, error_string, user_data)) { return -1; } @@ -327,7 +334,7 @@ static int parse_section(FILE *fp, } if (strcmp(path, "") != 0) { - *error_string = "Missing closing brace"; + *error_string = "parser error: Missing closing brace"; return -1; } @@ -1109,7 +1116,7 @@ static int read_uidgid_files_into_icmap( key_name[0] = 0; - res = parse_section(fp, key_name, error_string, uidgid_config_parser_cb, NULL); + res = parse_section(fp, key_name, error_string, 0, uidgid_config_parser_cb, NULL); fclose (fp); @@ -1154,7 +1161,7 @@ static int read_config_file_into_icmap( key_name[0] = 0; - res = parse_section(fp, key_name, error_string, main_config_parser_cb, &data); + res = parse_section(fp, key_name, error_string, 0, main_config_parser_cb, &data); fclose(fp); -- 1.7.1 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss