summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-01-13 19:48:18 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2017-01-13 19:48:18 +0100
commit275f8f4581bb76e8914ecdb7acd92bacfa41be3f (patch)
tree2ad977d34c818005e95ad004800c678189fe58fd
parentddb589b2632664e236175d94c5cd2178f992a532 (diff)
downloadnagios-plugin-curl-275f8f4581bb76e8914ecdb7acd92bacfa41be3f.tar.gz
nagios-plugin-curl-275f8f4581bb76e8914ecdb7acd92bacfa41be3f.tar.bz2
small conversion fixes around strtol and an uninitialized curl code
-rw-r--r--src/check_curl.c2
-rw-r--r--src/curlhelper.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/check_curl.c b/src/check_curl.c
index a9bf445..992cbf1 100644
--- a/src/check_curl.c
+++ b/src/check_curl.c
@@ -293,6 +293,7 @@ int main( int argc, char *argv[] ) {
}
if( strcmp( protocol, "http" ) == 0 ) {
+ curl_easy_getinfo( curl, CURLINFO_RESPONSE_CODE, &code );
/* get status line of answer, check sanity of HTTP code */
if( curlhelp_parse_statusline( header_buf.buf, &status_line ) < 0 ) {
printf( "HTTP CRITICAL HTTP/1.x %ld unknown - Unparseable status line in %.3g seconds response time|%s\n",
@@ -303,7 +304,6 @@ int main( int argc, char *argv[] ) {
curlhelp_freebuffer( &header_buf );
exit( STATE_CRITICAL );
}
- curl_easy_getinfo( curl, CURLINFO_RESPONSE_CODE, &code );
if( args_info.onredirect_given ) {
if( strcmp( args_info.onredirect_arg, "follow" ) == 0 ) {
code = status_line.http_code;
diff --git a/src/curlhelper.c b/src/curlhelper.c
index a2d442f..8bcd898 100644
--- a/src/curlhelper.c
+++ b/src/curlhelper.c
@@ -77,12 +77,12 @@ int curlhelp_parse_statusline( char *buf, curlhelp_statusline *status_line ) {
p = strtok( NULL, "." );
if( p == NULL ) { free( status_line->first_line ); return -1; }
- status_line->http_major = strtol( p, &pp, 10 );
+ status_line->http_major = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( status_line->first_line ); return -1; }
p = strtok( NULL, " " );
if( p == NULL ) { free( status_line->first_line ); return -1; }
- status_line->http_minor = strtol( p, &pp, 10 );
+ status_line->http_minor = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( status_line->first_line ); return -1; }
/* status code: "404" or "404.1", then SP */
@@ -92,14 +92,14 @@ int curlhelp_parse_statusline( char *buf, curlhelp_statusline *status_line ) {
if( strchr( p, '.' ) != NULL ) {
char *ppp;
ppp = strtok( p, "." );
- status_line->http_code = strtol( ppp, &pp, 10 );
+ status_line->http_code = (int)strtol( ppp, &pp, 10 );
if( *pp != '\0' ) { free( status_line->first_line ); return -1; }
ppp = strtok( NULL, "" );
- status_line->http_subcode = strtol( ppp, &pp, 10 );
+ status_line->http_subcode = (int)strtol( ppp, &pp, 10 );
if( *pp != '\0' ) { free( status_line->first_line ); return -1; }
} else {
- status_line->http_code = strtol( p, &pp, 10 );
+ status_line->http_code = (int)strtol( p, &pp, 10 );
status_line->http_subcode = -1;
if( *pp != '\0' ) { free( status_line->first_line ); return -1; }
}