From 7eb43858db118b89d13eb71bf07b2c110edb258b Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 7 May 2017 07:55:44 +0000 Subject: fixed some printf bugs and switched to libcurl4-openssl for Travis tests diff --git a/.travis.yml b/.travis.yml index ef53b2d..e725004 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ install: - sudo apt-get install -qq --no-install-recommends autoconf automake - sudo apt-get install -qq --no-install-recommends faketime - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl - - sudo apt-get install -qq --no-install-recommends libcurl3-gnutls-dev + - sudo apt-get install -qq --no-install-recommends libcurl4-openssl-dev # Trusty related dependencies (not yet provided) - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server # enable ssl apache diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 3ae1c4d..6856e78 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -711,14 +711,14 @@ GOT_FIRST_CERT: /* get status line of answer, check sanity of HTTP code */ if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparseable status line in %.3g seconds response time|%s\n", - code, total_time, perfstring); - die (STATE_CRITICAL, "HTTP CRITICAL HTTP/1.x %d unknown - %s", code, msg); + total_time, perfstring); + die (STATE_CRITICAL, "HTTP CRITICAL HTTP/1.x %ld unknown - %s", code, msg); } /* get result code from cURL */ handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); if (verbose>=2) - printf ("* curl CURLINFO_RESPONSE_CODE is %d\n", code); + printf ("* curl CURLINFO_RESPONSE_CODE is %ld\n", code); /* print status line, header, body if verbose */ if (verbose >= 2) { @@ -942,7 +942,7 @@ redir (curlhelp_write_curlbuf* header_buf) if (++redir_depth > max_depth) die (STATE_WARNING, - _("HTTP WARNING - maximum redirection depth %d exceeded - %s\n"), + _("HTTP WARNING - maximum redirection depth %d exceeded - %s%s\n"), max_depth, location, (display_html ? "" : "")); UriParserStateA state; @@ -1005,7 +1005,7 @@ redir (curlhelp_write_curlbuf* header_buf) } if (new_port > MAX_PORT) die (STATE_UNKNOWN, - _("HTTP UNKNOWN - Redirection to port above %d - %s\n"), + _("HTTP UNKNOWN - Redirection to port above %d - %s%s\n"), MAX_PORT, location, display_html ? "" : ""); /* by RFC 7231 relative URLs in Location should be taken relative to @@ -1239,7 +1239,8 @@ process_arguments (int argc, char **argv) http_method = strdup (optarg); break; case 'A': /* useragent */ - snprintf (user_agent, DEFAULT_BUFFER_SIZE, optarg); + strncpy (user_agent, optarg, DEFAULT_BUFFER_SIZE); + user_agent[DEFAULT_BUFFER_SIZE-1] = '\0'; break; case 'k': /* Additional headers */ if (http_opt_headers_count == 0) @@ -1524,7 +1525,7 @@ process_arguments (int argc, char **argv) if (critical_thresholds && thlds->critical->end>(double)socket_timeout) socket_timeout = (int)thlds->critical->end + 1; if (verbose >= 2) - printf ("* Socket timeout set to %d seconds\n", socket_timeout); + printf ("* Socket timeout set to %ld seconds\n", socket_timeout); if (http_method == NULL) http_method = strdup ("GET"); @@ -1722,7 +1723,7 @@ print_usage (void) printf (" [-e ] [-d string] [-s string] [-l] [-r | -R ]\n"); printf (" [-P string] [-m :] [-4|-6] [-N] [-M ]\n"); printf (" [-A string] [-k string] [-S ] [--sni] [-C [,]]\n"); - printf (" [-T ] [-j method]\n", progname); + printf (" [-T ] [-j method]\n"); printf ("\n"); printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); printf ("%s\n\n", _("check_http if you need a stable version.")); @@ -1969,7 +1970,7 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA time_t srv_data = curl_getdate (server_date, NULL); time_t doc_data = curl_getdate (document_date, NULL); if (verbose >= 2) - printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, srv_data, document_date, doc_data); + printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data); if (srv_data <= 0) { snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); date_result = max_state_alt(STATE_CRITICAL, date_result); -- cgit v0.10-9-g596f