diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2026-01-09 13:10:23 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2026-01-09 13:10:23 +0100 |
| commit | bbc0c8b29fdbefead8b49bc0bd77193f6fc83a1a (patch) | |
| tree | b2438e511560ec22e10997c7c59681380ed7c8e5 /plugins | |
| parent | 544ea5bf954abd3ba6bb1b3ec277539dd53c94b9 (diff) | |
| download | monitoring-plugins-bbc0c8b29fdbefead8b49bc0bd77193f6fc83a1a.tar.gz | |
check_curl: clang-format
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_curl.c | 24 |
1 files changed, 15 insertions, 9 deletions
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 | |||
| 775 | /* missing components have null,null in their UriTextRangeA | 775 | /* missing components have null,null in their UriTextRangeA |
| 776 | * add query parameters if they exist. | 776 | * add query parameters if they exist. |
| 777 | */ | 777 | */ |
| 778 | if (uri.query.first && uri.query.afterLast){ | 778 | if (uri.query.first && uri.query.afterLast) { |
| 779 | // Ensure we have space for '?' + query_str + '\0' ahead of time, instead of calling strncat twice | 779 | // Ensure we have space for '?' + query_str + '\0' ahead of time, instead of calling strncat |
| 780 | // twice | ||
| 780 | size_t current_len = strlen(new_url); | 781 | size_t current_len = strlen(new_url); |
| 781 | size_t remaining_space = DEFAULT_BUFFER_SIZE - current_len - 1; | 782 | size_t remaining_space = DEFAULT_BUFFER_SIZE - current_len - 1; |
| 782 | 783 | ||
| 783 | const char* query_str = uri_string(uri.query, buf, DEFAULT_BUFFER_SIZE); | 784 | const char *query_str = uri_string(uri.query, buf, DEFAULT_BUFFER_SIZE); |
| 784 | size_t query_str_len = strlen(query_str); | 785 | size_t query_str_len = strlen(query_str); |
| 785 | 786 | ||
| 786 | if (remaining_space >= query_str_len + 1) { | 787 | if (remaining_space >= query_str_len + 1) { |
| 787 | strcat(new_url, "?"); | 788 | strcat(new_url, "?"); |
| 788 | strcat(new_url, query_str); | 789 | strcat(new_url, query_str); |
| 789 | }else{ | 790 | } else { |
| 790 | 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 ); | 791 | die(STATE_UNKNOWN, |
| 792 | _("HTTP UNKNOWN - No space to add query part of size %zu to the buffer, buffer has " | ||
| 793 | "remaining size %zu"), | ||
| 794 | query_str_len, current_len); | ||
| 791 | } | 795 | } |
| 792 | } | 796 | } |
| 793 | 797 | ||
| @@ -1501,8 +1505,8 @@ void print_help(void) { | |||
| 1501 | printf(" %s\n", "-I, --IP-address=ADDRESS"); | 1505 | printf(" %s\n", "-I, --IP-address=ADDRESS"); |
| 1502 | printf(" %s\n", | 1506 | printf(" %s\n", |
| 1503 | "IP address or name (use numeric address if possible to bypass DNS lookup)."); | 1507 | "IP address or name (use numeric address if possible to bypass DNS lookup)."); |
| 1504 | printf(" %s\n", | 1508 | printf(" %s\n", "This overwrites the network address of the target while leaving everything " |
| 1505 | "This overwrites the network address of the target while leaving everything else (HTTP headers) as they are"); | 1509 | "else (HTTP headers) as they are"); |
| 1506 | printf(" %s\n", "-p, --port=INTEGER"); | 1510 | printf(" %s\n", "-p, --port=INTEGER"); |
| 1507 | printf(" %s", _("Port number (default: ")); | 1511 | printf(" %s", _("Port number (default: ")); |
| 1508 | printf("%d)\n", HTTP_PORT); | 1512 | printf("%d)\n", HTTP_PORT); |
| @@ -1566,7 +1570,8 @@ void print_help(void) { | |||
| 1566 | printf(" %s\n", _("String to expect in the content")); | 1570 | printf(" %s\n", _("String to expect in the content")); |
| 1567 | printf(" %s\n", "-u, --url=PATH"); | 1571 | printf(" %s\n", "-u, --url=PATH"); |
| 1568 | printf(" %s\n", _("URL to GET or POST (default: /)")); | 1572 | printf(" %s\n", _("URL to GET or POST (default: /)")); |
| 1569 | 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'")); | 1573 | printf(" %s\n", _("This is the part after the address in a URL, so for " |
| 1574 | "\"https://example.com/index.html\" it would be '-u /index.html'")); | ||
| 1570 | printf(" %s\n", "-P, --post=STRING"); | 1575 | printf(" %s\n", "-P, --post=STRING"); |
| 1571 | printf(" %s\n", _("URL decoded http POST data")); | 1576 | printf(" %s\n", _("URL decoded http POST data")); |
| 1572 | printf(" %s\n", | 1577 | printf(" %s\n", |
| @@ -1712,7 +1717,8 @@ void print_help(void) { | |||
| 1712 | printf(" %s\n", _("It is recommended to use an environment proxy like:")); | 1717 | printf(" %s\n", _("It is recommended to use an environment proxy like:")); |
| 1713 | printf(" %s\n", | 1718 | printf(" %s\n", |
| 1714 | _("https_proxy=http://192.168.100.35:3128 ./check_curl -H www.verisign.com -S")); | 1719 | _("https_proxy=http://192.168.100.35:3128 ./check_curl -H www.verisign.com -S")); |
| 1715 | printf(" %s\n", _("legacy proxy requests in check_http style might still work, but are frowned upon, so DONT:")); | 1720 | printf(" %s\n", _("legacy proxy requests in check_http style might still work, but are frowned " |
| 1721 | "upon, so DONT:")); | ||
| 1716 | printf(" %s\n", _("check_curl -I 192.168.100.35 -p 3128 -u https://www.verisign.com/ -S -j " | 1722 | printf(" %s\n", _("check_curl -I 192.168.100.35 -p 3128 -u https://www.verisign.com/ -S -j " |
| 1717 | "CONNECT -H www.verisign.com ")); | 1723 | "CONNECT -H www.verisign.com ")); |
| 1718 | printf(" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> " | 1724 | printf(" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> " |
