Parcourir la source

coroparse: Handle end of special sections

Special sections totem.interface, logging.logger_subsys,
logging.logging_daemon and nodelist.node executes extra code on end of
section. Previously, any end of section triggered handling, including
subsection one.

So for example config like:
```
nodelist {
  node {
    name: node1
    subs {
      key: val
    }
  }

  node {
    name: node2
    ...
```

result in node_number increased twice (once for end of "subs" section
and second time for end of "node" section) so node2 got number 2 instead
of 1.

Same was happening for all other special sections and may result in
crash as reported by vikk777 <listratenko1998@mail.ru> in
issues #783 and #784.

Solution is to execute extra code only for real end of section and not
for subsection.

This patch fixes only main problem but it creates keys without
subsection name what is not optimal.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse il y a 9 mois
Parent
commit
da5833e32e
1 fichiers modifiés avec 28 ajouts et 0 suppressions
  1. 28 0
      exec/coroparse.c

+ 28 - 0
exec/coroparse.c

@@ -1206,6 +1206,13 @@ static int main_config_parser_cb(const char *path,
 	case PARSER_CB_SECTION_END:
 	case PARSER_CB_SECTION_END:
 		switch (*state) {
 		switch (*state) {
 		case MAIN_CP_CB_DATA_STATE_INTERFACE:
 		case MAIN_CP_CB_DATA_STATE_INTERFACE:
+			if (strcmp(path, "totem.interface") != 0) {
+				/*
+				 * Process only end of totem.interface section, not subsections
+				 */
+				break;
+			}
+
 			/*
 			/*
 			 * Create new interface section
 			 * Create new interface section
 			 */
 			 */
@@ -1336,6 +1343,13 @@ static int main_config_parser_cb(const char *path,
 
 
 			break;
 			break;
 		case MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS:
 		case MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS:
+			if (strcmp(path, "logging.logger_subsys") != 0) {
+				/*
+				 * Process only end of logging.logger_subsys section, not subsections
+				 */
+				break;
+			}
+
 			if (data->subsys == NULL) {
 			if (data->subsys == NULL) {
 				*error_string = "No subsys key in logger_subsys directive";
 				*error_string = "No subsys key in logger_subsys directive";
 
 
@@ -1369,6 +1383,13 @@ static int main_config_parser_cb(const char *path,
 			}
 			}
 			break;
 			break;
 		case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON:
 		case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON:
+			if (strcmp(path, "logging.logging_daemon") != 0) {
+				/*
+				 * Process only end of logging.logging_daemon section, not subsections
+				 */
+				break;
+			}
+
 			if (data->logging_daemon_name == NULL) {
 			if (data->logging_daemon_name == NULL) {
 				*error_string = "No name key in logging_daemon directive";
 				*error_string = "No name key in logging_daemon directive";
 
 
@@ -1449,6 +1470,13 @@ static int main_config_parser_cb(const char *path,
 			}
 			}
 			break;
 			break;
 		case MAIN_CP_CB_DATA_STATE_NODELIST_NODE:
 		case MAIN_CP_CB_DATA_STATE_NODELIST_NODE:
+			if (strcmp(path, "nodelist.node") != 0) {
+				/*
+				 * Process only end of nodelist.node section, not subsections
+				 */
+				break;
+			}
+
 			data->node_number++;
 			data->node_number++;
 			break;
 			break;
 		case MAIN_CP_CB_DATA_STATE_NORMAL:
 		case MAIN_CP_CB_DATA_STATE_NORMAL: