From 43f691fef8d003edf6a6c849edb91d9be6f6082b Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sun, 25 Jan 2015 19:31:45 +0100 Subject: [PATCH] util-device: fix LiveBuildDeviceListCustom 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 | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/util-device.c b/src/util-device.c index a98b457597..c08e30f0b8 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -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++; } } }