From c1384375bc55c41bc79a1e1bcce57ffee263b52d Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:05:25 +0100 Subject: Fix some minor compiler warnings --- plugins/check_snmp.d/check_snmp_helpers.c | 10 ++++++---- plugins/check_snmp.d/check_snmp_helpers.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/check_snmp.d/check_snmp_helpers.c b/plugins/check_snmp.d/check_snmp_helpers.c index f506537a..2dfc88b5 100644 --- a/plugins/check_snmp.d/check_snmp_helpers.c +++ b/plugins/check_snmp.d/check_snmp_helpers.c @@ -36,7 +36,8 @@ int check_snmp_set_thresholds(const char *threshold_string, check_snmp_test_unit threshold_string++; } - for (char *ptr = strtok(threshold_string, ", "); ptr != NULL; + char *thr_string_copy = strdup(threshold_string); + for (char *ptr = strtok(thr_string_copy, ", "); ptr != NULL; ptr = strtok(NULL, ", "), tu_index++) { if (tu_index > max_test_units) { @@ -64,6 +65,7 @@ int check_snmp_set_thresholds(const char *threshold_string, check_snmp_test_unit } } + free(thr_string_copy); } else { // Single value // only valid for the first test unit @@ -843,8 +845,8 @@ char *_np_state_calculate_location_prefix(void) { * Sets variables. Generates filename. Returns np_state_key. die with * UNKNOWN if exception */ -state_key np_enable_state(char *keyname, int expected_data_version, char *plugin_name, int argc, - char **argv) { +state_key np_enable_state(char *keyname, int expected_data_version, const char *plugin_name, + int argc, char **argv) { state_key *this_state = (state_key *)calloc(1, sizeof(state_key)); if (this_state == NULL) { die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno)); @@ -869,7 +871,7 @@ state_key np_enable_state(char *keyname, int expected_data_version, char *plugin tmp_char++; } this_state->name = temp_keyname; - this_state->plugin_name = plugin_name; + this_state->plugin_name = (char *)plugin_name; this_state->data_version = expected_data_version; this_state->state_data = NULL; diff --git a/plugins/check_snmp.d/check_snmp_helpers.h b/plugins/check_snmp.d/check_snmp_helpers.h index 0f7780b1..95b361ac 100644 --- a/plugins/check_snmp.d/check_snmp_helpers.h +++ b/plugins/check_snmp.d/check_snmp_helpers.h @@ -66,6 +66,6 @@ typedef struct state_key_struct { } state_key; state_data *np_state_read(state_key stateKey); -state_key np_enable_state(char *keyname, int expected_data_version, char *plugin_name, int argc, - char **argv); +state_key np_enable_state(char *keyname, int expected_data_version, const char *plugin_name, + int argc, char **argv); void np_state_write_string(state_key stateKey, time_t timestamp, char *stringToStore); -- cgit v1.2.3-74-g34f1 From 544ea5bf954abd3ba6bb1b3ec277539dd53c94b9 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:09:46 +0100 Subject: Fix error message formatting --- plugins/check_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_curl.c b/plugins/check_curl.c index e7737c7c..0e84b96c 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -787,7 +787,7 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config strcat(new_url, "?"); strcat(new_url, query_str); }else{ - die(STATE_UNKNOWN, _("HTTP UNKNOWN - No space to add query part of size %d to the buffer, buffer has remaining size %d"), query_str_len , current_len ); + die(STATE_UNKNOWN, _("HTTP UNKNOWN - No space to add query part of size %zu to the buffer, buffer has remaining size %zu"), query_str_len , current_len ); } } -- cgit v1.2.3-74-g34f1 From bbc0c8b29fdbefead8b49bc0bd77193f6fc83a1a Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:10:23 +0100 Subject: check_curl: clang-format --- plugins/check_curl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 0e84b96c..1dec8a2a 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -775,19 +775,23 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config /* missing components have null,null in their UriTextRangeA * add query parameters if they exist. */ - if (uri.query.first && uri.query.afterLast){ - // Ensure we have space for '?' + query_str + '\0' ahead of time, instead of calling strncat twice + if (uri.query.first && uri.query.afterLast) { + // Ensure we have space for '?' + query_str + '\0' ahead of time, instead of calling strncat + // twice size_t current_len = strlen(new_url); size_t remaining_space = DEFAULT_BUFFER_SIZE - current_len - 1; - const char* query_str = uri_string(uri.query, buf, DEFAULT_BUFFER_SIZE); + const char *query_str = uri_string(uri.query, buf, DEFAULT_BUFFER_SIZE); size_t query_str_len = strlen(query_str); if (remaining_space >= query_str_len + 1) { strcat(new_url, "?"); strcat(new_url, query_str); - }else{ - die(STATE_UNKNOWN, _("HTTP UNKNOWN - No space to add query part of size %zu to the buffer, buffer has remaining size %zu"), query_str_len , current_len ); + } else { + die(STATE_UNKNOWN, + _("HTTP UNKNOWN - No space to add query part of size %zu to the buffer, buffer has " + "remaining size %zu"), + query_str_len, current_len); } } @@ -1501,8 +1505,8 @@ void print_help(void) { printf(" %s\n", "-I, --IP-address=ADDRESS"); printf(" %s\n", "IP address or name (use numeric address if possible to bypass DNS lookup)."); - printf(" %s\n", - "This overwrites the network address of the target while leaving everything else (HTTP headers) as they are"); + printf(" %s\n", "This overwrites the network address of the target while leaving everything " + "else (HTTP headers) as they are"); printf(" %s\n", "-p, --port=INTEGER"); printf(" %s", _("Port number (default: ")); printf("%d)\n", HTTP_PORT); @@ -1566,7 +1570,8 @@ void print_help(void) { printf(" %s\n", _("String to expect in the content")); printf(" %s\n", "-u, --url=PATH"); printf(" %s\n", _("URL to GET or POST (default: /)")); - printf(" %s\n", _("This is the part after the address in a URL, so for \"https://example.com/index.html\" it would be '-u /index.html'")); + printf(" %s\n", _("This is the part after the address in a URL, so for " + "\"https://example.com/index.html\" it would be '-u /index.html'")); printf(" %s\n", "-P, --post=STRING"); printf(" %s\n", _("URL decoded http POST data")); printf(" %s\n", @@ -1712,7 +1717,8 @@ void print_help(void) { printf(" %s\n", _("It is recommended to use an environment proxy like:")); printf(" %s\n", _("https_proxy=http://192.168.100.35:3128 ./check_curl -H www.verisign.com -S")); - printf(" %s\n", _("legacy proxy requests in check_http style might still work, but are frowned upon, so DONT:")); + printf(" %s\n", _("legacy proxy requests in check_http style might still work, but are frowned " + "upon, so DONT:")); printf(" %s\n", _("check_curl -I 192.168.100.35 -p 3128 -u https://www.verisign.com/ -S -j " "CONNECT -H www.verisign.com ")); printf(" %s\n", _("all these options are needed: -I -p -u " -- cgit v1.2.3-74-g34f1 From 35a13449955a969f10f74ac9cab9fed4531a1ca7 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:12:31 +0100 Subject: check_curl: fix pointer type --- plugins/check_curl.d/check_curl_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_curl.d/check_curl_helpers.c b/plugins/check_curl.d/check_curl_helpers.c index 7be781fc..5af00973 100644 --- a/plugins/check_curl.d/check_curl_helpers.c +++ b/plugins/check_curl.d/check_curl_helpers.c @@ -1214,7 +1214,7 @@ mp_subcheck check_curl_certificate_checks(CURL *curl, X509 *cert, int warn_days_ cert_ptr_union cert_ptr = {0}; cert_ptr.to_info = NULL; - CURLcode res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &cert_ptr.to_info); + CURLcode res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &cert_ptr.to_certinfo); if (!res && cert_ptr.to_info) { # ifdef USE_OPENSSL /* We have no OpenSSL in libcurl, but we can use OpenSSL for X509 cert -- cgit v1.2.3-74-g34f1