[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.3,1.4
Karl DeBisschop
kdebisschop at users.sourceforge.net
Mon Sep 23 22:17:02 CEST 2002
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv2127/plugins
Modified Files:
check_http.c
Log Message:
replace remaining occurences of sprintf with snprintf
Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_http.c 14 Sep 2002 02:23:55 -0000 1.3
--- check_http.c 24 Sep 2002 05:16:12 -0000 1.4
***************
*** 178,182 ****
#define HTTP_URL "/"
- time_t start_time, end_time;
char timestamp[10] = "";
int specify_port = FALSE;
--- 178,181 ----
***************
*** 184,190 ****
char server_port_text[6] = "";
char server_type[6] = "http";
! char *server_address = NULL;
! char *host_name = NULL;
! char *server_url = NULL;
int server_url_length = 0;
int server_expect_yn = 0;
--- 183,189 ----
char server_port_text[6] = "";
char server_type[6] = "http";
! /*@null@*/ char *server_address = NULL;
! /*@null@*/ char *host_name = NULL;
! /*@null@*/ char *server_url = NULL;
int server_url_length = 0;
int server_expect_yn = 0;
***************
*** 201,206 ****
int verbose = FALSE;
int sd;
! char *http_method = NULL;
! char *http_post_data = NULL;
char buffer[MAX_INPUT_BUFFER];
--- 200,205 ----
int verbose = FALSE;
int sd;
! /*@null@*/ char *http_method = NULL;
! /*@null@*/ char *http_post_data = NULL;
char buffer[MAX_INPUT_BUFFER];
***************
*** 224,230 ****
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
! sprintf (server_url, "%s&%s", server_url, timestamp);
else
! sprintf (server_url, "%s?%s", server_url, timestamp);
}
--- 223,229 ----
if (strstr (timestamp, ":")) {
if (strstr (server_url, "?"))
! server_url = ssprintf (server_url, "%s&%s", server_url, timestamp);
else
! server_url = ssprintf (server_url, "%s?%s", server_url, timestamp);
}
***************
*** 234,240 ****
/* initialize alarm signal handling, set socket timeout, start timer */
! signal (SIGALRM, socket_timeout_alarm_handler);
! alarm (socket_timeout);
! time (&start_time);
#ifdef HAVE_SSL
--- 233,239 ----
/* initialize alarm signal handling, set socket timeout, start timer */
! (void) signal (SIGALRM, socket_timeout_alarm_handler);
! (void) alarm (socket_timeout);
! (void) time (&start_time);
#ifdef HAVE_SSL
***************
*** 432,437 ****
#ifdef HAVE_REGEX_H
cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
! strncpy (regexp, optarg, MAX_INPUT_BUFFER - 1);
! regexp[MAX_INPUT_BUFFER - 1] = 0;
errcode = regcomp (&preg, regexp, cflags);
if (errcode != 0) {
--- 431,436 ----
#ifdef HAVE_REGEX_H
cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
! strncpy (regexp, optarg, MAX_RE_SIZE - 1);
! regexp[MAX_RE_SIZE - 1] = 0;
errcode = regcomp (&preg, regexp, cflags);
if (errcode != 0) {
***************
*** 488,494 ****
char BASE64_END = '=';
! char base64_table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
! "abcdefghijklmnopqrstuvwxyz"
! "0123456789+/";
while (j < len - 2) {
--- 487,491 ----
char BASE64_END = '=';
! char base64_table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
while (j < len - 2) {
***************
*** 553,557 ****
}
! sprintf (buffer, "%s %s HTTP/1.0\r\n", http_method, server_url);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
--- 550,554 ----
}
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "%s %s HTTP/1.0\r\n", http_method, server_url);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 561,565 ****
/* optionally send the host header info (not clear if it's usable) */
if (strcmp (host_name, "")) {
! sprintf (buffer, "Host: %s\r\n", host_name);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
--- 558,562 ----
/* optionally send the host header info (not clear if it's usable) */
if (strcmp (host_name, "")) {
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Host: %s\r\n", host_name);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 569,573 ****
/* send user agent */
! sprintf (buffer, "User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
--- 566,570 ----
/* send user agent */
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
***************
*** 579,583 ****
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! sprintf (buffer, "Authorization: Basic %s\r\n", auth);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
--- 576,580 ----
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Authorization: Basic %s\r\n", auth);
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 588,597 ****
/* optionally send http POST data */
if (http_post_data) {
! sprintf (buffer, "Content-Type: application/x-www-form-urlencoded\r\n");
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
! sprintf (buffer, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
--- 585,594 ----
/* optionally send http POST data */
if (http_post_data) {
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Content-Type: application/x-www-form-urlencoded\r\n");
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
return STATE_CRITICAL;
}
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 606,610 ****
/* send a newline so the server knows we're done with the request */
! sprintf (buffer, "\r\n\r\n");
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
--- 603,607 ----
/* send a newline so the server knows we're done with the request */
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "\r\n\r\n");
if (SSL_write (ssl, buffer, strlen (buffer)) == -1) {
ERR_print_errors_fp (stderr);
***************
*** 619,623 ****
terminate (STATE_CRITICAL, msg);
}
! sprintf (buffer, "%s %s HTTP/1.0\r\n", http_method, server_url);
send (sd, buffer, strlen (buffer), 0);
--- 616,620 ----
terminate (STATE_CRITICAL, msg);
}
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "%s %s HTTP/1.0\r\n", http_method, server_url);
send (sd, buffer, strlen (buffer), 0);
***************
*** 626,635 ****
/* optionally send the host header info */
if (strcmp (host_name, "")) {
! sprintf (buffer, "Host: %s\r\n", host_name);
send (sd, buffer, strlen (buffer), 0);
}
/* send user agent */
! sprintf (buffer,
"User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
--- 623,632 ----
/* optionally send the host header info */
if (strcmp (host_name, "")) {
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Host: %s\r\n", host_name);
send (sd, buffer, strlen (buffer), 0);
}
/* send user agent */
! snprintf (buffer, MAX_INPUT_BUFFER - 1,
"User-Agent: check_http/%s (nagios-plugins %s)\r\n",
clean_revstring (REVISION), PACKAGE_VERSION);
***************
*** 639,643 ****
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! sprintf (buffer, "Authorization: Basic %s\r\n", auth);
send (sd, buffer, strlen (buffer), 0);
}
--- 636,640 ----
if (strcmp (user_auth, "")) {
auth = base64 (user_auth, strlen (user_auth));
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Authorization: Basic %s\r\n", auth);
send (sd, buffer, strlen (buffer), 0);
}
***************
*** 646,652 ****
/* written by Chris Henesy <lurker at shadowtech.org> */
if (http_post_data) {
! sprintf (buffer, "Content-Type: application/x-www-form-urlencoded\r\n");
send (sd, buffer, strlen (buffer), 0);
! sprintf (buffer, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
send (sd, buffer, strlen (buffer), 0);
http_post_data = strscat (http_post_data, "\r\n");
--- 643,649 ----
/* written by Chris Henesy <lurker at shadowtech.org> */
if (http_post_data) {
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Content-Type: application/x-www-form-urlencoded\r\n");
send (sd, buffer, strlen (buffer), 0);
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "Content-Length: %i\r\n\r\n", strlen (http_post_data));
send (sd, buffer, strlen (buffer), 0);
http_post_data = strscat (http_post_data, "\r\n");
***************
*** 655,659 ****
/* send a newline so the server knows we're done with the request */
! sprintf (buffer, "\r\n\r\n");
send (sd, buffer, strlen (buffer), 0);
#ifdef HAVE_SSL
--- 652,656 ----
/* send a newline so the server knows we're done with the request */
! snprintf (buffer, MAX_INPUT_BUFFER - 1, "\r\n\r\n");
send (sd, buffer, strlen (buffer), 0);
#ifdef HAVE_SSL
***************
*** 994,999 ****
days_left = (mktime (&stamp) - time (NULL)) / 86400;
! sprintf
! (timestamp, "%02d/%02d/%04d %02d:%02d",
stamp.tm_mon + 1,
stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
--- 991,996 ----
days_left = (mktime (&stamp) - time (NULL)) / 86400;
! snprintf
! (timestamp, MAX_INPUT_BUFFER - 1, "%02d/%02d/%04d %02d:%02d",
stamp.tm_mon + 1,
stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
More information about the Commits
mailing list