summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 02:10:57 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2024-10-31 02:10:57 (GMT)
commitfde8e9c77b094ccec536d05c634d9d8f1f0e3abc (patch)
tree01e7f9847ded1fad9004dac857108371488c7910 /plugins/check_curl.c
parent7334812a929768aa310557ae823b91df79b32f51 (diff)
downloadmonitoring-plugins-fde8e9c77b094ccec536d05c634d9d8f1f0e3abc.tar.gz
check_curl: Linter fixes
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 06fc6d6..1d27da2 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -225,41 +225,41 @@ static bool automatic_decompression = false;
225static char *cookie_jar_file = NULL; 225static char *cookie_jar_file = NULL;
226static bool haproxy_protocol = false; 226static bool haproxy_protocol = false;
227 227
228static bool process_arguments(int, char **); 228static bool process_arguments(int /*argc*/, char ** /*argv*/);
229static void handle_curl_option_return_code(CURLcode res, const char *option); 229static void handle_curl_option_return_code(CURLcode res, const char *option);
230static int check_http(void); 230static int check_http(void);
231static void redir(curlhelp_write_curlbuf *); 231static void redir(curlhelp_write_curlbuf * /*header_buf*/);
232static char *perfd_time(double microsec); 232static char *perfd_time(double elapsed_time);
233static char *perfd_time_connect(double microsec); 233static char *perfd_time_connect(double elapsed_time_connect);
234static char *perfd_time_ssl(double microsec); 234static char *perfd_time_ssl(double elapsed_time_ssl);
235static char *perfd_time_firstbyte(double microsec); 235static char *perfd_time_firstbyte(double elapsed_time_firstbyte);
236static char *perfd_time_headers(double microsec); 236static char *perfd_time_headers(double elapsed_time_headers);
237static char *perfd_time_transfer(double microsec); 237static char *perfd_time_transfer(double elapsed_time_transfer);
238static char *perfd_size(int page_len); 238static char *perfd_size(int page_len);
239static void print_help(void); 239static void print_help(void);
240void print_usage(void); 240void print_usage(void);
241static void print_curl_version(void); 241static void print_curl_version(void);
242static int curlhelp_initwritebuffer(curlhelp_write_curlbuf *); 242static int curlhelp_initwritebuffer(curlhelp_write_curlbuf * /*buf*/);
243static size_t curlhelp_buffer_write_callback(void *, size_t, size_t, void *); 243static size_t curlhelp_buffer_write_callback(void * /*buffer*/, size_t /*size*/, size_t /*nmemb*/, void * /*stream*/);
244static void curlhelp_freewritebuffer(curlhelp_write_curlbuf *); 244static void curlhelp_freewritebuffer(curlhelp_write_curlbuf * /*buf*/);
245static int curlhelp_initreadbuffer(curlhelp_read_curlbuf *, const char *, size_t); 245static int curlhelp_initreadbuffer(curlhelp_read_curlbuf * /*buf*/, const char * /*data*/, size_t /*datalen*/);
246static size_t curlhelp_buffer_read_callback(void *, size_t, size_t, void *); 246static size_t curlhelp_buffer_read_callback(void * /*buffer*/, size_t /*size*/, size_t /*nmemb*/, void * /*stream*/);
247static void curlhelp_freereadbuffer(curlhelp_read_curlbuf *); 247static void curlhelp_freereadbuffer(curlhelp_read_curlbuf * /*buf*/);
248static curlhelp_ssl_library curlhelp_get_ssl_library(); 248static curlhelp_ssl_library curlhelp_get_ssl_library(void);
249static const char *curlhelp_get_ssl_library_string(curlhelp_ssl_library); 249static const char *curlhelp_get_ssl_library_string(curlhelp_ssl_library /*ssl_library*/);
250int net_noopenssl_check_certificate(cert_ptr_union *, int, int); 250int net_noopenssl_check_certificate(cert_ptr_union *, int, int);
251 251
252static int curlhelp_parse_statusline(const char *, curlhelp_statusline *); 252static int curlhelp_parse_statusline(const char * /*buf*/, curlhelp_statusline * /*status_line*/);
253static void curlhelp_free_statusline(curlhelp_statusline *); 253static void curlhelp_free_statusline(curlhelp_statusline * /*status_line*/);
254static char *get_header_value(const struct phr_header *headers, const size_t nof_headers, const char *header); 254static char *get_header_value(const struct phr_header *headers, size_t nof_headers, const char *header);
255static int check_document_dates(const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]); 255static int check_document_dates(const curlhelp_write_curlbuf * /*header_buf*/, char (*msg)[DEFAULT_BUFFER_SIZE]);
256static int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_write_curlbuf *body_buf); 256static int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_write_curlbuf *body_buf);
257 257
258#if defined(HAVE_SSL) && defined(USE_OPENSSL) 258#if defined(HAVE_SSL) && defined(USE_OPENSSL)
259int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit); 259int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit);
260#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ 260#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
261 261
262static void test_file(char *); 262static void test_file(char * /*path*/);
263 263
264int main(int argc, char **argv) { 264int main(int argc, char **argv) {
265 int result = STATE_UNKNOWN; 265 int result = STATE_UNKNOWN;
@@ -301,7 +301,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) {
301# endif 301# endif
302 if (verbose >= 2) { 302 if (verbose >= 2) {
303 puts("* SSL verify callback with certificate:"); 303 puts("* SSL verify callback with certificate:");
304 X509_NAME *subject, *issuer; 304 X509_NAME *subject;
305 X509_NAME *issuer;
305 printf("* issuer:\n"); 306 printf("* issuer:\n");
306 issuer = X509_get_issuer_name(cert); 307 issuer = X509_get_issuer_name(cert);
307 X509_NAME_print_ex_fp(stdout, issuer, 5, XN_FLAG_MULTILINE); 308 X509_NAME_print_ex_fp(stdout, issuer, 5, XN_FLAG_MULTILINE);
@@ -356,7 +357,8 @@ static char *string_statuscode(int major, int minor) {
356 357
357/* Checks if the server 'reply' is one of the expected 'statuscodes' */ 358/* Checks if the server 'reply' is one of the expected 'statuscodes' */
358static int expected_statuscode(const char *reply, const char *statuscodes) { 359static int expected_statuscode(const char *reply, const char *statuscodes) {
359 char *expected, *code; 360 char *expected;
361 char *code;
360 int result = 0; 362 int result = 0;
361 363
362 if ((expected = strdup(statuscodes)) == NULL) 364 if ((expected = strdup(statuscodes)) == NULL)
@@ -523,7 +525,7 @@ int check_http(void) {
523 // use the host_name later on to make SNI happy 525 // use the host_name later on to make SNI happy
524 if (use_ssl && host_name != NULL) { 526 if (use_ssl && host_name != NULL) {
525 if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) { 527 if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) {
526 snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), server_address, res, 528 snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %d"), server_address, res,
527 gai_strerror(res)); 529 gai_strerror(res));
528 die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 530 die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
529 } 531 }
@@ -2183,8 +2185,7 @@ const char *strrstr2(const char *haystack, const char *needle) {
2183 if (pos == NULL) { 2185 if (pos == NULL) {
2184 if (counter == 0) 2186 if (counter == 0)
2185 return NULL; 2187 return NULL;
2186 else 2188 return prev_pos;
2187 return prev_pos;
2188 } 2189 }
2189 counter++; 2190 counter++;
2190 prev_pos = pos; 2191 prev_pos = pos;
@@ -2438,7 +2439,7 @@ int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_
2438} 2439}
2439 2440
2440/* TODO: is there a better way in libcurl to check for the SSL library? */ 2441/* TODO: is there a better way in libcurl to check for the SSL library? */
2441curlhelp_ssl_library curlhelp_get_ssl_library() { 2442curlhelp_ssl_library curlhelp_get_ssl_library(void) {
2442 curl_version_info_data *version_data; 2443 curl_version_info_data *version_data;
2443 char *ssl_version; 2444 char *ssl_version;
2444 char *library; 2445 char *library;