]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-device: fix LiveBuildDeviceListCustom
authorEric Leblond <eric@regit.org>
Sun, 25 Jan 2015 18:31:45 +0000 (19:31 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 8 May 2015 09:37:12 +0000 (11:37 +0200)
The code was assuming that the dictionnary containing the parameter
of a interface was ordered. But for YAML, the order is not assumed
so in case the configuration is generated we may not be able to
parse correctly the configuration file.

By iterating on child on main node and then iterating on subchild
and doing a match on the name, we are able to find the interface
list. In term of code, this algorithm was obtained by simply
removing the test on the name of the first child.

src/util-device.c

index a98b45759743fc33e3aecf57c67f6f7b8ff5d8e5..c08e30f0b89d29b7af3b7b44d5ea4e3cdaf230ff 100644 (file)
@@ -151,17 +151,15 @@ int LiveBuildDeviceListCustom(char * runmode, char * itemname)
         return 0;
 
     TAILQ_FOREACH(child, &base->head, next) {
-        if (!strcmp(child->val, itemname)) {
-            ConfNode *subchild;
-            TAILQ_FOREACH(subchild, &child->head, next) {
-                if ((!strcmp(subchild->name, itemname))) {
-                    if (!strcmp(subchild->val, "default"))
-                        break;
-                    SCLogInfo("Adding %s %s from config file",
-                              itemname, subchild->val);
-                    LiveRegisterDevice(subchild->val);
-                    i++;
-                }
+        ConfNode *subchild;
+        TAILQ_FOREACH(subchild, &child->head, next) {
+            if ((!strcmp(subchild->name, itemname))) {
+                if (!strcmp(subchild->val, "default"))
+                    break;
+                SCLogInfo("Adding %s %s from config file",
+                          itemname, subchild->val);
+                LiveRegisterDevice(subchild->val);
+                i++;
             }
         }
     }