From: Peter Holik Date: Thu, 19 Feb 2009 12:00:59 +0000 (+0100) Subject: ipmi plugin: Fix an off-by-one error. X-Git-Tag: collectd-4.5.3~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8968a5cccc0729d7438df22260eee6ce5536cd0a;p=collectd.git ipmi plugin: Fix an off-by-one error. Hi, One of my ipmi sensors has a name longer than DATA_MAX_NAME_LEN and this results in a SEGV. cu Peter --- diff --git a/src/ipmi.c b/src/ipmi.c index f3ba95a8..f026c171 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -225,7 +225,7 @@ static int sensor_list_add (ipmi_sensor_t *sensor) ipmi_sensor_get_name (sensor, sensor_name, sizeof (sensor_name)); sensor_name[sizeof (sensor_name) - 1] = 0; - len = DATA_MAX_NAME_LEN - strlen(sensor_name); + len = DATA_MAX_NAME_LEN - strlen(sensor_name) - 1; strncat(sensor_name, " ", len--); strncat(sensor_name, ipmi_entity_get_entity_id_string(ent), len); @@ -237,7 +237,7 @@ static int sensor_list_add (ipmi_sensor_t *sensor) char *sensor_name_ptr_id = strstr (sensor_name, "("); sensor_name_ptr += 2; - len = DATA_MAX_NAME_LEN - strlen(sensor_name); + len = DATA_MAX_NAME_LEN - strlen(sensor_name) - 1; strncat(sensor_name, " ", len--); strncat(sensor_name, sensor_name_ptr_id, MIN(sensor_name_ptr - sensor_name_ptr_id - 1, len));