From a73e5d6532bed1216e86af5c15b0acd9fb555026 Mon Sep 17 00:00:00 2001 From: Mariusz Szafranski Date: Thu, 29 Mar 2018 09:45:46 +0100 Subject: [PATCH] ipmi plugin: Fix for segmentation fault for wrong data type in Sensor section. 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 --- src/ipmi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ipmi.c b/src/ipmi.c index 6a72b2b7..98cc3b05 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -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) -- 2.11.0