ipmi plugin: Fix for segmentation fault for wrong data type in Sensor section.
authorMariusz Szafranski <mariuszx.szafranski@intel.com>
Thu, 29 Mar 2018 08:45:46 +0000 (09:45 +0100)
committerMariusz Szafranski <mariuszx.szafranski@intel.com>
Wed, 16 May 2018 09:51:09 +0000 (10:51 +0100)
Incorrect, malicious data in the Sensor section can cause a segmentation fault.
Error message is generated instead of crash after applying this patch.

Change-Id: Ibc387b5594f9453f1fc957ed37ceb09cfa34ded5
Signed-off-by: Mariusz Szafranski <mariuszx.szafranski@intel.com>
src/ipmi.c

index 6a72b2b..98cc3b0 100644 (file)
@@ -1062,9 +1062,14 @@ static int c_ipmi_config_add_instance(oconfig_item_t *ci) {
   for (int i = 0; i < ci->children_num; i++) {
     oconfig_item_t *child = ci->children + i;
 
-    if (strcasecmp("Sensor", child->key) == 0)
-      ignorelist_add(st->ignorelist, child->values[0].value.string);
-    else if (strcasecmp("IgnoreSelected", child->key) == 0) {
+    if (strcasecmp("Sensor", child->key) == 0) {
+      char *value = NULL;
+      status = cf_util_get_string(child, &value);
+      if (status != 0)
+        break;
+      ignorelist_add(st->ignorelist, value);
+      sfree(value);
+    } else if (strcasecmp("IgnoreSelected", child->key) == 0) {
       _Bool t;
       status = cf_util_get_boolean(child, &t);
       if (status != 0)