summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-08-30 14:19:06 +0200
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-08-30 14:19:06 +0200
commita7c6760cfe46fce4010056b8cdc36a1c9bd1d366 (patch)
treefad2c285a2f0319a61760c447d2c83df36befd1a /plugins/check_snmp.c
parent7f1877f760a5ecdd0356010dd14c7606d44abfb0 (diff)
downloadmonitoring-plugins-a7c6760cfe46fce4010056b8cdc36a1c9bd1d366.tar.gz
check_snmp: Small improvements + fix dereference bug
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c7
1 files changed, 4 insertions, 3 deletions
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) {
214 sc_oid_test.output = strdup(""); 214 sc_oid_test.output = strdup("");
215 } 215 }
216 216
217 char oid_string[(MAX_OID_LEN * 2) + 1]; 217 char oid_string[(MAX_OID_LEN * 2) + 1] = {};
218 memset(oid_string, 0, (MAX_OID_LEN * 2) + 1);
219 218
220 int oid_string_result = 219 int oid_string_result =
221 snprint_objid(oid_string, (MAX_OID_LEN * 2) + 1, vars->name, vars->name_length); 220 snprint_objid(oid_string, (MAX_OID_LEN * 2) + 1, vars->name, vars->name_length);
@@ -404,9 +403,11 @@ int main(int argc, char **argv) {
404 // Use oid for perdata label 403 // Use oid for perdata label
405 pd_num_val.label = strdup(oid_string); 404 pd_num_val.label = strdup(oid_string);
406 // TODO strdup error checking 405 // TODO strdup error checking
407 } else if (config.test_units[loop_index].label != NULL || 406 } else if (config.test_units[loop_index].label != NULL &&
408 strcmp(config.test_units[loop_index].label, "") != 0) { 407 strcmp(config.test_units[loop_index].label, "") != 0) {
409 pd_num_val.label = config.test_units[loop_index].label; 408 pd_num_val.label = config.test_units[loop_index].label;
409 } else {
410 pd_num_val.label = config.test_units[loop_index].oid;
410 } 411 }
411 412
412 if (config.test_units[loop_index].unit_value != NULL && 413 if (config.test_units[loop_index].unit_value != NULL &&