From a7c6760cfe46fce4010056b8cdc36a1c9bd1d366 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sat, 30 Aug 2025 14:19:06 +0200 Subject: check_snmp: Small improvements + fix dereference bug --- plugins/check_snmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plugins/check_snmp.c') diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 0a9c6752..d5abd8c2 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -214,8 +214,7 @@ int main(int argc, char **argv) { sc_oid_test.output = strdup(""); } - char oid_string[(MAX_OID_LEN * 2) + 1]; - memset(oid_string, 0, (MAX_OID_LEN * 2) + 1); + char oid_string[(MAX_OID_LEN * 2) + 1] = {}; int oid_string_result = snprint_objid(oid_string, (MAX_OID_LEN * 2) + 1, vars->name, vars->name_length); @@ -404,9 +403,11 @@ int main(int argc, char **argv) { // Use oid for perdata label pd_num_val.label = strdup(oid_string); // TODO strdup error checking - } else if (config.test_units[loop_index].label != NULL || + } else if (config.test_units[loop_index].label != NULL && strcmp(config.test_units[loop_index].label, "") != 0) { pd_num_val.label = config.test_units[loop_index].label; + } else { + pd_num_val.label = config.test_units[loop_index].oid; } if (config.test_units[loop_index].unit_value != NULL && -- cgit v1.2.3-74-g34f1