diff options
| author | Andreas Baumann <mail@andreasbaumann.cc> | 2026-01-23 10:10:30 +0100 |
|---|---|---|
| committer | Andreas Baumann <mail@andreasbaumann.cc> | 2026-01-23 10:10:30 +0100 |
| commit | d28be4a00c5e2f3433b3d030aeac5ee656dc565d (patch) | |
| tree | 0aac73a89b209b4210fd783c4e0b1becf56a69f3 /plugins/check_snmp.d | |
| parent | 38f601be58071da7a30caa442b5e997632f2dd6c (diff) | |
| download | monitoring-plugins-d28be4a00c5e2f3433b3d030aeac5ee656dc565d.tar.gz | |
check_snmp_helpers.c: various possible fixes around const char */char * casts
Diffstat (limited to 'plugins/check_snmp.d')
| -rw-r--r-- | plugins/check_snmp.d/check_snmp_helpers.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/plugins/check_snmp.d/check_snmp_helpers.c b/plugins/check_snmp.d/check_snmp_helpers.c index 2dfc88b5..d680678a 100644 --- a/plugins/check_snmp.d/check_snmp_helpers.c +++ b/plugins/check_snmp.d/check_snmp_helpers.c | |||
| @@ -91,6 +91,8 @@ const char DEFAULT_OUTPUT_DELIMITER[] = " "; | |||
| 91 | 91 | ||
| 92 | const int RANDOM_STATE_DATA_LENGTH_PREDICTION = 8192; | 92 | const int RANDOM_STATE_DATA_LENGTH_PREDICTION = 8192; |
| 93 | 93 | ||
| 94 | char community[100]; | ||
| 95 | |||
| 94 | check_snmp_config check_snmp_config_init() { | 96 | check_snmp_config check_snmp_config_init() { |
| 95 | check_snmp_config tmp = { | 97 | check_snmp_config tmp = { |
| 96 | .snmp_params = | 98 | .snmp_params = |
| @@ -129,14 +131,17 @@ check_snmp_config check_snmp_config_init() { | |||
| 129 | tmp.snmp_params.snmp_session.retries = DEFAULT_RETRIES; | 131 | tmp.snmp_params.snmp_session.retries = DEFAULT_RETRIES; |
| 130 | tmp.snmp_params.snmp_session.version = DEFAULT_SNMP_VERSION; | 132 | tmp.snmp_params.snmp_session.version = DEFAULT_SNMP_VERSION; |
| 131 | tmp.snmp_params.snmp_session.securityLevel = SNMP_SEC_LEVEL_NOAUTH; | 133 | tmp.snmp_params.snmp_session.securityLevel = SNMP_SEC_LEVEL_NOAUTH; |
| 132 | tmp.snmp_params.snmp_session.community = (unsigned char *)"public"; | 134 | strcpy(community, "public"); |
| 133 | tmp.snmp_params.snmp_session.community_len = strlen("public"); | 135 | tmp.snmp_params.snmp_session.community = (unsigned char *)community; |
| 136 | tmp.snmp_params.snmp_session.community_len = strlen(community); | ||
| 134 | return tmp; | 137 | return tmp; |
| 135 | } | 138 | } |
| 136 | 139 | ||
| 137 | snmp_responces do_snmp_query(check_snmp_config_snmp_parameters parameters) { | 140 | snmp_responces do_snmp_query(check_snmp_config_snmp_parameters parameters) { |
| 138 | if (parameters.ignore_mib_parsing_errors) { | 141 | if (parameters.ignore_mib_parsing_errors) { |
| 139 | char *opt_toggle_res = snmp_mib_toggle_options("e"); | 142 | char option_e[2]; |
| 143 | option_e[0] = 'e'; option_e[1] = '\0'; | ||
| 144 | char *opt_toggle_res = snmp_mib_toggle_options(option_e); | ||
| 140 | if (opt_toggle_res != NULL) { | 145 | if (opt_toggle_res != NULL) { |
| 141 | die(STATE_UNKNOWN, "Unable to disable MIB parsing errors"); | 146 | die(STATE_UNKNOWN, "Unable to disable MIB parsing errors"); |
| 142 | } | 147 | } |
| @@ -436,7 +441,7 @@ check_snmp_evaluation evaluate_single_unit(response_value response, | |||
| 436 | } | 441 | } |
| 437 | } else { | 442 | } else { |
| 438 | // It's only a counter if we cont compute rate | 443 | // It's only a counter if we cont compute rate |
| 439 | pd_num_val.uom = "c"; | 444 | pd_num_val.uom = strdup("c"); |
| 440 | pd_result_val = mp_create_pd_value(response.value.uIntVal); | 445 | pd_result_val = mp_create_pd_value(response.value.uIntVal); |
| 441 | } | 446 | } |
| 442 | break; | 447 | break; |
| @@ -476,7 +481,7 @@ check_snmp_evaluation evaluate_single_unit(response_value response, | |||
| 476 | pd_result_val = mp_create_pd_value(treated_value); | 481 | pd_result_val = mp_create_pd_value(treated_value); |
| 477 | 482 | ||
| 478 | if (response.type == ASN_COUNTER) { | 483 | if (response.type == ASN_COUNTER) { |
| 479 | pd_num_val.uom = "c"; | 484 | pd_num_val.uom = strdup("c"); |
| 480 | } | 485 | } |
| 481 | } | 486 | } |
| 482 | 487 | ||
| @@ -820,7 +825,7 @@ state_data *np_state_read(state_key stateKey) { | |||
| 820 | * envvar NAGIOS_PLUGIN_STATE_DIRECTORY | 825 | * envvar NAGIOS_PLUGIN_STATE_DIRECTORY |
| 821 | * statically compiled shared state directory | 826 | * statically compiled shared state directory |
| 822 | */ | 827 | */ |
| 823 | char *_np_state_calculate_location_prefix(void) { | 828 | static const char *_np_state_calculate_location_prefix(void) { |
| 824 | char *env_dir; | 829 | char *env_dir; |
| 825 | 830 | ||
| 826 | /* Do not allow passing MP_STATE_PATH in setuid plugins | 831 | /* Do not allow passing MP_STATE_PATH in setuid plugins |
| @@ -871,7 +876,7 @@ state_key np_enable_state(char *keyname, int expected_data_version, const char * | |||
| 871 | tmp_char++; | 876 | tmp_char++; |
| 872 | } | 877 | } |
| 873 | this_state->name = temp_keyname; | 878 | this_state->name = temp_keyname; |
| 874 | this_state->plugin_name = (char *)plugin_name; | 879 | this_state->plugin_name = strdup(plugin_name); |
| 875 | this_state->data_version = expected_data_version; | 880 | this_state->data_version = expected_data_version; |
| 876 | this_state->state_data = NULL; | 881 | this_state->state_data = NULL; |
| 877 | 882 | ||
