]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf: fix include handling from arrays
authorJason Ish <jason.ish@oisf.net>
Thu, 7 Sep 2023 17:53:55 +0000 (11:53 -0600)
committerVictor Julien <victor@inliniac.net>
Fri, 15 Sep 2023 15:08:58 +0000 (17:08 +0200)
Includes from an "include" array were being loaded into the wrong
parent as the logic for array handing in include context was not
updated.

If we are descending into an array in include context, pass through
the current parent so the included configuration is included where it
is expected.

Bug: #6300

src/conf-yaml-loader.c

index 9312a189e8a4e7426d79609fa9e7af0d26f9b071..1bd107e0c1c984482daa141743e16a9529545f35 100644 (file)
@@ -374,8 +374,9 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int
         }
         else if (event.type == YAML_SEQUENCE_START_EVENT) {
             SCLogDebug("event.type=YAML_SEQUENCE_START_EVENT; state=%d", state);
-            if (ConfYamlParse(parser, node, 1, rlevel, state == CONF_INCLUDE ? CONF_INCLUDE : 0) !=
-                    0)
+            /* If we're processing a list of includes, use the current parent. */
+            if (ConfYamlParse(parser, state == CONF_INCLUDE ? parent : node, 1, rlevel,
+                        state == CONF_INCLUDE ? CONF_INCLUDE : 0) != 0)
                 goto fail;
             node->is_seq = 1;
             state = CONF_KEY;