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.
pull/1473/head
Eric Leblond 11 years ago committed by Victor Julien
parent 268285c49f
commit 43f691fef8

@ -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++;
}
}
}

Loading…
Cancel
Save