summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2012-06-29 00:57:48 -0400
committerHolger Weiss <holger@zedat.fu-berlin.de>2012-06-29 13:39:11 +0200
commit028d50d6f99e647a325a0a68303016382c4bbdc9 (patch)
tree1d9a14635602169d137409becfa108cd6bdb371c
parent9976876584e5a1df6e1c9315212c3d274df7a12e (diff)
downloadmonitoring-plugins-028d50d6f99e647a325a0a68303016382c4bbdc9.tar.gz
Die when asprintf fails
Fixes many instances of warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] Signed-off-by: Anders Kaseorg <andersk@mit.edu>
-rw-r--r--contrib/check_http-with-client-certificate.c142
-rw-r--r--plugins/check_by_ssh.c10
-rw-r--r--plugins/check_dig.c4
-rw-r--r--plugins/check_disk.c24
-rw-r--r--plugins/check_dns.c8
-rw-r--r--plugins/check_fping.c6
-rw-r--r--plugins/check_game.c4
-rw-r--r--plugins/check_hpjd.c2
-rw-r--r--plugins/check_http.c78
-rw-r--r--plugins/check_ldap.c8
-rw-r--r--plugins/check_load.c2
-rw-r--r--plugins/check_mrtgtraf.c2
-rw-r--r--plugins/check_mysql.c2
-rw-r--r--plugins/check_mysql_query.c4
-rw-r--r--plugins/check_nagios.c2
-rw-r--r--plugins/check_nt.c52
-rw-r--r--plugins/check_ntp.c20
-rw-r--r--plugins/check_ntp_peer.c36
-rw-r--r--plugins/check_ntp_time.c16
-rw-r--r--plugins/check_nwstat.c204
-rw-r--r--plugins/check_overcr.c2
-rw-r--r--plugins/check_pgsql.c2
-rw-r--r--plugins/check_ping.c10
-rw-r--r--plugins/check_procs.c34
-rw-r--r--plugins/check_radius.c2
-rw-r--r--plugins/check_real.c2
-rw-r--r--plugins/check_smtp.c30
-rw-r--r--plugins/check_snmp.c34
-rw-r--r--plugins/check_ssh.c4
-rw-r--r--plugins/check_swap.c16
-rw-r--r--plugins/check_tcp.c4
-rw-r--r--plugins/check_time.c2
-rw-r--r--plugins/check_ups.c60
-rw-r--r--plugins/check_users.c2
-rw-r--r--plugins/negate.c2
-rw-r--r--plugins/urlize.c2
-rw-r--r--plugins/utils.c67
-rw-r--r--plugins/utils.h2
38 files changed, 466 insertions, 437 deletions
diff --git a/contrib/check_http-with-client-certificate.c b/contrib/check_http-with-client-certificate.c
index 60e14812..c47cbd4f 100644
--- a/contrib/check_http-with-client-certificate.c
+++ b/contrib/check_http-with-client-certificate.c
@@ -606,7 +606,7 @@ process_arguments( int argc, char **argv )
606 *if ( !is_hostname( optarg ) ) 606 *if ( !is_hostname( optarg ) )
607 * usage2( "invalid hostname", optarg ); 607 * usage2( "invalid hostname", optarg );
608 */ 608 */
609 asprintf( &server_hostname, "%s", optarg ); 609 xasprintf( &server_hostname, "%s", optarg );
610 use_server_hostname = TRUE; 610 use_server_hostname = TRUE;
611 break; 611 break;
612 case 'F': /* File (dummy) */ 612 case 'F': /* File (dummy) */
@@ -619,7 +619,7 @@ process_arguments( int argc, char **argv )
619 *if ( !is_host( optarg ) ) 619 *if ( !is_host( optarg ) )
620 * usage2( "invalid ip address or hostname", optarg ) 620 * usage2( "invalid ip address or hostname", optarg )
621 */ 621 */
622 asprintf( &server_host, "%s", optarg ); 622 xasprintf( &server_host, "%s", optarg );
623 break; 623 break;
624 case 'p': /* Server port */ 624 case 'p': /* Server port */
625 if ( !is_intnonneg( optarg ) ) 625 if ( !is_intnonneg( optarg ) )
@@ -653,7 +653,7 @@ process_arguments( int argc, char **argv )
653 break; 653 break;
654 case 'A': /* client certificate */ 654 case 'A': /* client certificate */
655#ifdef HAVE_SSL 655#ifdef HAVE_SSL
656 asprintf( &client_certificate_file, "%s", optarg ); 656 xasprintf( &client_certificate_file, "%s", optarg );
657 use_client_certificate = TRUE; 657 use_client_certificate = TRUE;
658#else 658#else
659 usage( "check_http: invalid option - SSL is not available\n" ); 659 usage( "check_http: invalid option - SSL is not available\n" );
@@ -661,26 +661,26 @@ process_arguments( int argc, char **argv )
661 break; 661 break;
662 case 'K': /* client certificate passphrase */ 662 case 'K': /* client certificate passphrase */
663#ifdef HAVE_SSL 663#ifdef HAVE_SSL
664 asprintf( &client_certificate_passphrase, "%s", optarg ); 664 xasprintf( &client_certificate_passphrase, "%s", optarg );
665 use_client_certificate_passphrase = TRUE; 665 use_client_certificate_passphrase = TRUE;
666#else 666#else
667 usage( "check_http: invalid option - SSL is not available\n" ); 667 usage( "check_http: invalid option - SSL is not available\n" );
668#endif 668#endif
669 case 'Z': /* valid CA certificates */ 669 case 'Z': /* valid CA certificates */
670#ifdef HAVE_SSL 670#ifdef HAVE_SSL
671 asprintf( &ca_certificate_file, "%s", optarg ); 671 xasprintf( &ca_certificate_file, "%s", optarg );
672 use_ca_certificate = TRUE; 672 use_ca_certificate = TRUE;
673#else 673#else
674 usage( "check_http: invalid option - SSL is not available\n" ); 674 usage( "check_http: invalid option - SSL is not available\n" );
675#endif 675#endif
676 break; 676 break;
677 case 'u': /* URL PATH */ 677 case 'u': /* URL PATH */
678 asprintf( &http_url_path, "%s", optarg ); 678 xasprintf( &http_url_path, "%s", optarg );
679 break; 679 break;
680 case 'P': /* POST DATA */ 680 case 'P': /* POST DATA */
681 asprintf( &http_post_data, "%s", optarg ); 681 xasprintf( &http_post_data, "%s", optarg );
682 use_http_post_data = TRUE; 682 use_http_post_data = TRUE;
683 asprintf( &http_method, "%s", "POST" ); 683 xasprintf( &http_method, "%s", "POST" );
684 break; 684 break;
685 case 'e': /* expected string in first line of HTTP response */ 685 case 'e': /* expected string in first line of HTTP response */
686 strncpy( http_expect , optarg, MAX_INPUT_BUFFER - 1 ); 686 strncpy( http_expect , optarg, MAX_INPUT_BUFFER - 1 );
@@ -765,13 +765,13 @@ process_arguments( int argc, char **argv )
765 * without an option 765 * without an option
766 */ 766 */
767 if ( ( strcmp( server_host, "" ) ) && (c < argc) ) { 767 if ( ( strcmp( server_host, "" ) ) && (c < argc) ) {
768 asprintf( &server_host, "%s", argv[c++] ); 768 xasprintf( &server_host, "%s", argv[c++] );
769 } 769 }
770 770
771 /* 2. check if another artument is supplied 771 /* 2. check if another artument is supplied
772 */ 772 */
773 if ( ( strcmp( server_hostname, "" ) == 0 ) && (c < argc) ) { 773 if ( ( strcmp( server_hostname, "" ) == 0 ) && (c < argc) ) {
774 asprintf( &server_hostname, "%s", argv[c++] ); 774 xasprintf( &server_hostname, "%s", argv[c++] );
775 } 775 }
776 776
777 /* 3. if host is still not defined, just copy hostname, 777 /* 3. if host is still not defined, just copy hostname,
@@ -781,7 +781,7 @@ process_arguments( int argc, char **argv )
781 if ( strcmp( server_hostname, "" ) == 0 ) { 781 if ( strcmp( server_hostname, "" ) == 0 ) {
782 usage ("check_http: you must specify a server address or host name\n"); 782 usage ("check_http: you must specify a server address or host name\n");
783 } else { 783 } else {
784 asprintf( &server_host, "%s", server_hostname ); 784 xasprintf( &server_host, "%s", server_hostname );
785 } 785 }
786 } 786 }
787 787
@@ -807,9 +807,9 @@ process_arguments( int argc, char **argv )
807 807
808 /* Finally set some default values if necessary */ 808 /* Finally set some default values if necessary */
809 if ( strcmp( http_method, "" ) == 0 ) 809 if ( strcmp( http_method, "" ) == 0 )
810 asprintf( &http_method, "%s", DEFAULT_HTTP_METHOD ); 810 xasprintf( &http_method, "%s", DEFAULT_HTTP_METHOD );
811 if ( strcmp( http_url_path, "" ) == 0 ) { 811 if ( strcmp( http_url_path, "" ) == 0 ) {
812 asprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH ); 812 xasprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH );
813 } 813 }
814 814
815 return TRUE; 815 return TRUE;
@@ -829,25 +829,25 @@ http_request( int sock, struct pageref *page )
829 size_t size = 0; 829 size_t size = 0;
830 char *basic_auth_encoded = NULL; 830 char *basic_auth_encoded = NULL;
831 831
832 asprintf( &buffer, HTTP_TEMPLATE_REQUEST, buffer, http_method, http_url_path ); 832 xasprintf( &buffer, HTTP_TEMPLATE_REQUEST, buffer, http_method, http_url_path );
833 833
834 asprintf( &buffer, HTTP_TEMPLATE_HEADER_USERAGENT, buffer, progname, REVISION, PACKAGE_VERSION ); 834 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_USERAGENT, buffer, progname, REVISION, PACKAGE_VERSION );
835 835
836 if ( use_server_hostname ) { 836 if ( use_server_hostname ) {
837 asprintf( &buffer, HTTP_TEMPLATE_HEADER_HOST, buffer, server_hostname ); 837 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_HOST, buffer, server_hostname );
838 } 838 }
839 839
840 if ( use_basic_auth ) { 840 if ( use_basic_auth ) {
841 basic_auth_encoded = base64( basic_auth, strlen( basic_auth ) ); 841 basic_auth_encoded = base64( basic_auth, strlen( basic_auth ) );
842 asprintf( &buffer, HTTP_TEMPLATE_HEADER_AUTH, buffer, basic_auth_encoded ); 842 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_AUTH, buffer, basic_auth_encoded );
843 } 843 }
844 844
845 /* either send http POST data */ 845 /* either send http POST data */
846 if ( use_http_post_data ) { 846 if ( use_http_post_data ) {
847 /* based on code written by Chris Henesy <lurker@shadowtech.org> */ 847 /* based on code written by Chris Henesy <lurker@shadowtech.org> */
848 asprintf( &buffer, "Content-Type: application/x-www-form-urlencoded\r\n" ); 848 xasprintf( &buffer, "Content-Type: application/x-www-form-urlencoded\r\n" );
849 asprintf( &buffer, "Content-Length: %i\r\n\r\n", buffer, content_len ); 849 xasprintf( &buffer, "Content-Length: %i\r\n\r\n", buffer, content_len );
850 asprintf( &buffer, "%s%s%s", buffer, http_post_data, "\r\n" ); 850 xasprintf( &buffer, "%s%s%s", buffer, http_post_data, "\r\n" );
851 sendsize = send( sock, buffer, strlen( buffer ), 0 ); 851 sendsize = send( sock, buffer, strlen( buffer ), 0 );
852 if ( sendsize < strlen( buffer ) ) { 852 if ( sendsize < strlen( buffer ) ) {
853 printf( "ERROR: Incomplete write\n" ); 853 printf( "ERROR: Incomplete write\n" );
@@ -855,7 +855,7 @@ http_request( int sock, struct pageref *page )
855 } 855 }
856 /* or just a newline */ 856 /* or just a newline */
857 } else { 857 } else {
858 asprintf( &buffer, "%s%s", buffer, "\r\n" ); 858 xasprintf( &buffer, "%s%s", buffer, "\r\n" );
859 sendsize = send( sock, buffer, strlen( buffer ) , 0 ); 859 sendsize = send( sock, buffer, strlen( buffer ) , 0 );
860 if ( sendsize < strlen( buffer ) ) { 860 if ( sendsize < strlen( buffer ) ) {
861 printf( "ERROR: Incomplete write\n" ); 861 printf( "ERROR: Incomplete write\n" );
@@ -870,12 +870,12 @@ http_request( int sock, struct pageref *page )
870 recvsize = recv( sock, recvbuff, MAX_INPUT_BUFFER - 1, 0 ); 870 recvsize = recv( sock, recvbuff, MAX_INPUT_BUFFER - 1, 0 );
871 if ( recvsize > (size_t) 0 ) { 871 if ( recvsize > (size_t) 0 ) {
872 recvbuff[recvsize] = '\0'; 872 recvbuff[recvsize] = '\0';
873 asprintf( &content, "%s%s", content, recvbuff ); 873 xasprintf( &content, "%s%s", content, recvbuff );
874 size += recvsize; 874 size += recvsize;
875 } 875 }
876 } while ( recvsize > (size_t) 0 ); 876 } while ( recvsize > (size_t) 0 );
877 877
878 asprintf( &page->content, "%s", content ); 878 xasprintf( &page->content, "%s", content );
879 page->size = size; 879 page->size = size;
880 880
881 /* return a CRITICAL status if we couldn't read any data */ 881 /* return a CRITICAL status if we couldn't read any data */
@@ -895,7 +895,7 @@ parse_http_response( struct pageref *page )
895 size_t len = 0; //temporary used 895 size_t len = 0; //temporary used
896 char *pos = ""; //temporary used 896 char *pos = ""; //temporary used
897 897
898 asprintf( &content, "%s", page->content ); 898 xasprintf( &content, "%s", page->content );
899 899
900 /* find status line and null-terminate it */ 900 /* find status line and null-terminate it */
901 // copy content to status 901 // copy content to status
@@ -962,7 +962,7 @@ check_http_response( struct pageref *page )
962 962
963 /* check response time befor anything else */ 963 /* check response time befor anything else */
964 if ( use_critical_interval && ( elapsed_time > critical_interval ) ) { 964 if ( use_critical_interval && ( elapsed_time > critical_interval ) ) {
965 asprintf( &msg, RESULT_TEMPLATE_RESPONSE_TIME, 965 xasprintf( &msg, RESULT_TEMPLATE_RESPONSE_TIME,
966 protocol_text( use_ssl ), 966 protocol_text( use_ssl ),
967 state_text( STATE_CRITICAL ), 967 state_text( STATE_CRITICAL ),
968 elapsed_time, 968 elapsed_time,
@@ -970,7 +970,7 @@ check_http_response( struct pageref *page )
970 terminate( STATE_CRITICAL, msg ); 970 terminate( STATE_CRITICAL, msg );
971 } 971 }
972 if ( use_warning_interval && ( elapsed_time > warning_interval ) ) { 972 if ( use_warning_interval && ( elapsed_time > warning_interval ) ) {
973 asprintf( &msg, RESULT_TEMPLATE_RESPONSE_TIME, 973 xasprintf( &msg, RESULT_TEMPLATE_RESPONSE_TIME,
974 protocol_text( use_ssl ), 974 protocol_text( use_ssl ),
975 state_text( STATE_WARNING ), 975 state_text( STATE_WARNING ),
976 elapsed_time, 976 elapsed_time,
@@ -990,9 +990,9 @@ check_http_response( struct pageref *page )
990#else 990#else
991 ) 991 )
992#endif 992#endif
993 asprintf( &msg, "Expected HTTP response received from host\n" ); 993 xasprintf( &msg, "Expected HTTP response received from host\n" );
994 else 994 else
995 asprintf( &msg, "Expected HTTP response received from host on port %d\n", server_port ); 995 xasprintf( &msg, "Expected HTTP response received from host on port %d\n", server_port );
996 terminate( STATE_OK, msg ); 996 terminate( STATE_OK, msg );
997 } 997 }
998 } else { 998 } else {
@@ -1002,9 +1002,9 @@ check_http_response( struct pageref *page )
1002#else 1002#else
1003 ) 1003 )
1004#endif 1004#endif
1005 asprintf( &msg, "Invalid HTTP response received from host\n" ); 1005 xasprintf( &msg, "Invalid HTTP response received from host\n" );
1006 else 1006 else
1007 asprintf( &msg, "Invalid HTTP response received from host on port %d\n", server_port ); 1007 xasprintf( &msg, "Invalid HTTP response received from host on port %d\n", server_port );
1008 terminate( STATE_CRITICAL, msg ); 1008 terminate( STATE_CRITICAL, msg );
1009 } 1009 }
1010 1010
@@ -1016,7 +1016,7 @@ check_http_response( struct pageref *page )
1016 strstr( page->status, "503" ) || 1016 strstr( page->status, "503" ) ||
1017 strstr( page->status, "504" ) || 1017 strstr( page->status, "504" ) ||
1018 strstr( page->status, "505" )) { 1018 strstr( page->status, "505" )) {
1019 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1019 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1020 protocol_text( use_ssl ), 1020 protocol_text( use_ssl ),
1021 state_text( http_client_error_state ), 1021 state_text( http_client_error_state ),
1022 page->status, 1022 page->status,
@@ -1044,7 +1044,7 @@ check_http_response( struct pageref *page )
1044 strstr( page->status, "415" ) || 1044 strstr( page->status, "415" ) ||
1045 strstr( page->status, "416" ) || 1045 strstr( page->status, "416" ) ||
1046 strstr( page->status, "417" ) ) { 1046 strstr( page->status, "417" ) ) {
1047 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1047 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1048 protocol_text( use_ssl ), 1048 protocol_text( use_ssl ),
1049 state_text( http_client_error_state ), 1049 state_text( http_client_error_state ),
1050 page->status, 1050 page->status,
@@ -1066,7 +1066,7 @@ check_http_response( struct pageref *page )
1066 /* returning STATE_DEPENDENT means follow redirect */ 1066 /* returning STATE_DEPENDENT means follow redirect */
1067 return STATE_DEPENDENT; 1067 return STATE_DEPENDENT;
1068 } else { 1068 } else {
1069 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1069 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1070 protocol_text( use_ssl ), 1070 protocol_text( use_ssl ),
1071 state_text( http_redirect_state ), 1071 state_text( http_redirect_state ),
1072 page->status, 1072 page->status,
@@ -1087,7 +1087,7 @@ check_http_content( struct pageref *page )
1087 /* check for string in content */ 1087 /* check for string in content */
1088 if ( check_content_string ) { 1088 if ( check_content_string ) {
1089 if ( strstr( page->content, content_string ) ) { 1089 if ( strstr( page->content, content_string ) ) {
1090 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1090 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1091 protocol_text( use_ssl ), 1091 protocol_text( use_ssl ),
1092 state_text( STATE_OK ), 1092 state_text( STATE_OK ),
1093 page->status, 1093 page->status,
@@ -1095,7 +1095,7 @@ check_http_content( struct pageref *page )
1095 elapsed_time ); 1095 elapsed_time );
1096 terminate( STATE_OK, msg ); 1096 terminate( STATE_OK, msg );
1097 } else { 1097 } else {
1098 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1098 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1099 protocol_text( use_ssl ), 1099 protocol_text( use_ssl ),
1100 state_text( STATE_CRITICAL ), 1100 state_text( STATE_CRITICAL ),
1101 page->status, 1101 page->status,
@@ -1110,7 +1110,7 @@ check_http_content( struct pageref *page )
1110 if ( check_content_regex ) { 1110 if ( check_content_regex ) {
1111 regex_error = regexec( &regex_preg, page->content, REGEX_REGS, regex_pmatch, 0); 1111 regex_error = regexec( &regex_preg, page->content, REGEX_REGS, regex_pmatch, 0);
1112 if ( regex_error == 0 ) { 1112 if ( regex_error == 0 ) {
1113 asprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME, 1113 xasprintf( &msg, RESULT_TEMPLATE_STATUS_RESPONSE_TIME,
1114 protocol_text( use_ssl ), 1114 protocol_text( use_ssl ),
1115 state_text( STATE_OK ), 1115 state_text( STATE_OK ),
1116 page->status, 1116 page->status,
@@ -1119,13 +1119,13 @@ check_http_content( struct pageref *page )
1119 terminate( STATE_OK, msg ); 1119 terminate( STATE_OK, msg );
1120 } else { 1120 } else {
1121 if ( regex_error == REG_NOMATCH ) { 1121 if ( regex_error == REG_NOMATCH ) {
1122 asprintf( &msg, "%s, %s: regex pattern not found\n", 1122 xasprintf( &msg, "%s, %s: regex pattern not found\n",
1123 protocol_text( use_ssl) , 1123 protocol_text( use_ssl) ,
1124 state_text( STATE_CRITICAL ) ); 1124 state_text( STATE_CRITICAL ) );
1125 terminate( STATE_CRITICAL, msg ); 1125 terminate( STATE_CRITICAL, msg );
1126 } else { 1126 } else {
1127 regerror( regex_error, &regex_preg, regex_error_buffer, MAX_INPUT_BUFFER); 1127 regerror( regex_error, &regex_preg, regex_error_buffer, MAX_INPUT_BUFFER);
1128 asprintf( &msg, "%s %s: Regex execute Error: %s\n", 1128 xasprintf( &msg, "%s %s: Regex execute Error: %s\n",
1129 protocol_text( use_ssl) , 1129 protocol_text( use_ssl) ,
1130 state_text( STATE_CRITICAL ), 1130 state_text( STATE_CRITICAL ),
1131 regex_error_buffer ); 1131 regex_error_buffer );
@@ -1152,16 +1152,16 @@ prepare_follow_redirect( struct pageref *page )
1152 char *orig_url_dirname = NULL; 1152 char *orig_url_dirname = NULL;
1153 size_t len = 0; 1153 size_t len = 0;
1154 1154
1155 asprintf( &header, "%s", page->header ); 1155 xasprintf( &header, "%s", page->header );
1156 1156
1157 1157
1158 /* restore some default values */ 1158 /* restore some default values */
1159 use_http_post_data = FALSE; 1159 use_http_post_data = FALSE;
1160 asprintf( &http_method, "%s", DEFAULT_HTTP_METHOD ); 1160 xasprintf( &http_method, "%s", DEFAULT_HTTP_METHOD );
1161 1161
1162 /* copy url of original request, maybe we need it to compose 1162 /* copy url of original request, maybe we need it to compose
1163 absolute url from relative Location: header */ 1163 absolute url from relative Location: header */
1164 asprintf( &orig_url_path, "%s", http_url_path ); 1164 xasprintf( &orig_url_path, "%s", http_url_path );
1165 1165
1166 while ( strcspn( header, "\r\n" ) > (size_t) 0 ) { 1166 while ( strcspn( header, "\r\n" ) > (size_t) 0 ) {
1167 url_path = realloc( url_path, (size_t) strcspn( header, "\r\n" ) ); 1167 url_path = realloc( url_path, (size_t) strcspn( header, "\r\n" ) );
@@ -1172,43 +1172,43 @@ prepare_follow_redirect( struct pageref *page )
1172 /* Try to find a Location header combination of METHOD HOSTNAME PORT and PATH */ 1172 /* Try to find a Location header combination of METHOD HOSTNAME PORT and PATH */
1173 /* 1. scan for Location: http[s]://hostname:port/path */ 1173 /* 1. scan for Location: http[s]://hostname:port/path */
1174 if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_PORT_MATCH HTTP_HEADER_URL_PATH_MATCH, &protocol, &hostname, &port, url_path ) == 4 ) { 1174 if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_PORT_MATCH HTTP_HEADER_URL_PATH_MATCH, &protocol, &hostname, &port, url_path ) == 4 ) {
1175 asprintf( &server_hostname, "%s", hostname ); 1175 xasprintf( &server_hostname, "%s", hostname );
1176 asprintf( &server_host, "%s", hostname ); 1176 xasprintf( &server_host, "%s", hostname );
1177 use_ssl = chk_protocol(protocol); 1177 use_ssl = chk_protocol(protocol);
1178 server_port = atoi( port ); 1178 server_port = atoi( port );
1179 asprintf( &http_url_path, "%s", url_path ); 1179 xasprintf( &http_url_path, "%s", url_path );
1180 return STATE_DEPENDENT; 1180 return STATE_DEPENDENT;
1181 } 1181 }
1182 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_URL_PATH_MATCH, &protocol, &hostname, url_path ) == 3) { 1182 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_URL_PATH_MATCH, &protocol, &hostname, url_path ) == 3) {
1183 asprintf( &server_hostname, "%s", hostname ); 1183 xasprintf( &server_hostname, "%s", hostname );
1184 asprintf( &server_host, "%s", hostname ); 1184 xasprintf( &server_host, "%s", hostname );
1185 use_ssl = chk_protocol(protocol); 1185 use_ssl = chk_protocol(protocol);
1186 server_port = protocol_std_port(use_ssl); 1186 server_port = protocol_std_port(use_ssl);
1187 asprintf( &http_url_path, "%s", url_path ); 1187 xasprintf( &http_url_path, "%s", url_path );
1188 return STATE_DEPENDENT; 1188 return STATE_DEPENDENT;
1189 } 1189 }
1190 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_PORT_MATCH, &protocol, &hostname, &port ) == 3) { 1190 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH HTTP_HEADER_PORT_MATCH, &protocol, &hostname, &port ) == 3) {
1191 asprintf( &server_hostname, "%s", hostname ); 1191 xasprintf( &server_hostname, "%s", hostname );
1192 asprintf( &server_host, "%s", hostname ); 1192 xasprintf( &server_host, "%s", hostname );
1193 use_ssl = chk_protocol(protocol); 1193 use_ssl = chk_protocol(protocol);
1194 server_port = atoi( port ); 1194 server_port = atoi( port );
1195 asprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH ); 1195 xasprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH );
1196 return STATE_DEPENDENT; 1196 return STATE_DEPENDENT;
1197 } 1197 }
1198 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH, protocol, hostname ) == 2 ) { 1198 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_PROTOCOL_MATCH HTTP_HEADER_HOSTNAME_MATCH, protocol, hostname ) == 2 ) {
1199 asprintf( &server_hostname, "%s", hostname ); 1199 xasprintf( &server_hostname, "%s", hostname );
1200 asprintf( &server_host, "%s", hostname ); 1200 xasprintf( &server_host, "%s", hostname );
1201 use_ssl = chk_protocol(protocol); 1201 use_ssl = chk_protocol(protocol);
1202 server_port = protocol_std_port(use_ssl); 1202 server_port = protocol_std_port(use_ssl);
1203 asprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH ); 1203 xasprintf( &http_url_path, "%s", DEFAULT_HTTP_URL_PATH );
1204 } 1204 }
1205 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_URL_PATH_MATCH, url_path ) == 1 ) { 1205 else if ( sscanf ( header, HTTP_HEADER_LOCATION_MATCH HTTP_HEADER_URL_PATH_MATCH, url_path ) == 1 ) {
1206 /* check for relative url and prepend path if necessary */ 1206 /* check for relative url and prepend path if necessary */
1207 if ( ( url_path[0] != '/' ) && ( orig_url_dirname = strrchr( orig_url_path, '/' ) ) ) { 1207 if ( ( url_path[0] != '/' ) && ( orig_url_dirname = strrchr( orig_url_path, '/' ) ) ) {
1208 *orig_url_dirname = '\0'; 1208 *orig_url_dirname = '\0';
1209 asprintf( &http_url_path, "%s%s", orig_url_path, url_path ); 1209 xasprintf( &http_url_path, "%s%s", orig_url_path, url_path );
1210 } else { 1210 } else {
1211 asprintf( &http_url_path, "%s", url_path ); 1211 xasprintf( &http_url_path, "%s", url_path );
1212 } 1212 }
1213 return STATE_DEPENDENT; 1213 return STATE_DEPENDENT;
1214 } 1214 }
@@ -1218,7 +1218,7 @@ prepare_follow_redirect( struct pageref *page )
1218 1218
1219 1219
1220 /* default return value is STATE_DEPENDENT to continue looping in main() */ 1220 /* default return value is STATE_DEPENDENT to continue looping in main() */
1221 asprintf( &msg, "% %: % - Could not find redirect Location", 1221 xasprintf( &msg, "% %: % - Could not find redirect Location",
1222 protocol_text( use_ssl ), 1222 protocol_text( use_ssl ),
1223 state_text( STATE_UNKNOWN ), 1223 state_text( STATE_UNKNOWN ),
1224 page->status ); 1224 page->status );
@@ -1239,24 +1239,24 @@ https_request( SSL_CTX *ctx, SSL *ssl, struct pageref *page )
1239 size_t size = 0; 1239 size_t size = 0;
1240 char *basic_auth_encoded = NULL; 1240 char *basic_auth_encoded = NULL;
1241 1241
1242 asprintf( &buffer, HTTP_TEMPLATE_REQUEST, buffer, http_method, http_url_path ); 1242 xasprintf( &buffer, HTTP_TEMPLATE_REQUEST, buffer, http_method, http_url_path );
1243 1243
1244 asprintf( &buffer, HTTP_TEMPLATE_HEADER_USERAGENT, buffer, progname, REVISION, PACKAGE_VERSION ); 1244 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_USERAGENT, buffer, progname, REVISION, PACKAGE_VERSION );
1245 1245
1246 if ( use_server_hostname ) { 1246 if ( use_server_hostname ) {
1247 asprintf( &buffer, HTTP_TEMPLATE_HEADER_HOST, buffer, server_hostname ); 1247 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_HOST, buffer, server_hostname );
1248 } 1248 }
1249 1249
1250 if ( use_basic_auth ) { 1250 if ( use_basic_auth ) {
1251 basic_auth_encoded = base64( basic_auth, strlen( basic_auth ) ); 1251 basic_auth_encoded = base64( basic_auth, strlen( basic_auth ) );
1252 asprintf( &buffer, HTTP_TEMPLATE_HEADER_AUTH, buffer, basic_auth_encoded ); 1252 xasprintf( &buffer, HTTP_TEMPLATE_HEADER_AUTH, buffer, basic_auth_encoded );
1253 } 1253 }
1254 1254
1255 /* either send http POST data */ 1255 /* either send http POST data */
1256 if ( use_http_post_data ) { 1256 if ( use_http_post_data ) {
1257 asprintf( &buffer, "%sContent-Type: application/x-www-form-urlencoded\r\n", buffer ); 1257 xasprintf( &buffer, "%sContent-Type: application/x-www-form-urlencoded\r\n", buffer );
1258 asprintf( &buffer, "%sContent-Length: %i\r\n\r\n", buffer, content_len ); 1258 xasprintf( &buffer, "%sContent-Length: %i\r\n\r\n", buffer, content_len );
1259 asprintf( &buffer, "%s%s%s", buffer, http_post_data, "\r\n" ); 1259 xasprintf( &buffer, "%s%s%s", buffer, http_post_data, "\r\n" );
1260 sendsize = SSL_write( ssl, buffer, strlen( buffer ) ); 1260 sendsize = SSL_write( ssl, buffer, strlen( buffer ) );
1261 switch ( SSL_get_error( ssl, sendsize ) ) { 1261 switch ( SSL_get_error( ssl, sendsize ) ) {
1262 case SSL_ERROR_NONE: 1262 case SSL_ERROR_NONE:
@@ -1270,7 +1270,7 @@ https_request( SSL_CTX *ctx, SSL *ssl, struct pageref *page )
1270 /* or just a newline */ 1270 /* or just a newline */
1271 } else { 1271 } else {
1272 1272
1273 asprintf( &buffer, "%s\r\n", buffer ); 1273 xasprintf( &buffer, "%s\r\n", buffer );
1274 sendsize = SSL_write( ssl, buffer, strlen( buffer ) ); 1274 sendsize = SSL_write( ssl, buffer, strlen( buffer ) );
1275 switch ( SSL_get_error( ssl, sendsize ) ) { 1275 switch ( SSL_get_error( ssl, sendsize ) ) {
1276 case SSL_ERROR_NONE: 1276 case SSL_ERROR_NONE:
@@ -1293,7 +1293,7 @@ https_request( SSL_CTX *ctx, SSL *ssl, struct pageref *page )
1293 case SSL_ERROR_NONE: 1293 case SSL_ERROR_NONE:
1294 if ( recvsize > (size_t) 0 ) { 1294 if ( recvsize > (size_t) 0 ) {
1295 recvbuff[recvsize] = '\0'; 1295 recvbuff[recvsize] = '\0';
1296 asprintf( &content, "%s%s", content, recvbuff ); 1296 xasprintf( &content, "%s%s", content, recvbuff );
1297 size += recvsize; 1297 size += recvsize;
1298 } 1298 }
1299 break; 1299 break;
@@ -1317,7 +1317,7 @@ https_request( SSL_CTX *ctx, SSL *ssl, struct pageref *page )
1317 } 1317 }
1318 } while ( recvsize > (size_t) 0 ); 1318 } while ( recvsize > (size_t) 0 );
1319 1319
1320 asprintf( &page->content, "%s", content ); 1320 xasprintf( &page->content, "%s", content );
1321 page->size = size; 1321 page->size = size;
1322 1322
1323 /* return a CRITICAL status if we couldn't read any data */ 1323 /* return a CRITICAL status if we couldn't read any data */
@@ -1446,7 +1446,7 @@ check_server_certificate_hostname( )
1446 char *msg = NULL; 1446 char *msg = NULL;
1447 X509_NAME_get_text_by_NID( X509_get_subject_name( server_certificate ), NID_commonName, server_CN, 256 ); 1447 X509_NAME_get_text_by_NID( X509_get_subject_name( server_certificate ), NID_commonName, server_CN, 256 );
1448 if ( strcasecmp( server_CN, server_hostname ) ) { 1448 if ( strcasecmp( server_CN, server_hostname ) ) {
1449 asprintf( &msg, "SSL ERROR: Server Certificate does not match Hostname %s.\n", server_hostname ); 1449 xasprintf( &msg, "SSL ERROR: Server Certificate does not match Hostname %s.\n", server_hostname );
1450 ssl_terminate( STATE_WARNING, msg ); 1450 ssl_terminate( STATE_WARNING, msg );
1451 } 1451 }
1452 1452
@@ -1507,20 +1507,20 @@ check_server_certificate_expires( )
1507 stamp.tm_hour, stamp.tm_min ); 1507 stamp.tm_hour, stamp.tm_min );
1508 1508
1509 if ( ( days_left > 0 ) && ( days_left <= server_certificate_min_days_valid ) ) { 1509 if ( ( days_left > 0 ) && ( days_left <= server_certificate_min_days_valid ) ) {
1510 asprintf( &msg, "Certificate expires in %d day(s) (%s).\n", days_left, timestamp ); 1510 xasprintf( &msg, "Certificate expires in %d day(s) (%s).\n", days_left, timestamp );
1511 ssl_terminate( STATE_WARNING, msg ); 1511 ssl_terminate( STATE_WARNING, msg );
1512 } 1512 }
1513 if ( days_left < 0 ) { 1513 if ( days_left < 0 ) {
1514 asprintf( &msg, "Certificate expired on %s.\n", timestamp ); 1514 xasprintf( &msg, "Certificate expired on %s.\n", timestamp );
1515 ssl_terminate( STATE_CRITICAL, msg ); 1515 ssl_terminate( STATE_CRITICAL, msg );
1516 } 1516 }
1517 1517
1518 if (days_left == 0) { 1518 if (days_left == 0) {
1519 asprintf( &msg, "Certificate expires today (%s).\n", timestamp ); 1519 xasprintf( &msg, "Certificate expires today (%s).\n", timestamp );
1520 ssl_terminate( STATE_WARNING, msg ); 1520 ssl_terminate( STATE_WARNING, msg );
1521 } 1521 }
1522 1522
1523 asprintf( &msg, "Certificate will expire on %s.\n", timestamp ); 1523 xasprintf( &msg, "Certificate will expire on %s.\n", timestamp );
1524 ssl_terminate( STATE_OK, msg ); 1524 ssl_terminate( STATE_OK, msg );
1525} 1525}
1526#endif 1526#endif
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 87520166..c5f0d529 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -281,8 +281,8 @@ process_arguments (int argc, char **argv)
281 case 'C': /* Command for remote machine */ 281 case 'C': /* Command for remote machine */
282 commands++; 282 commands++;
283 if (commands > 1) 283 if (commands > 1)
284 asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd); 284 xasprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
285 asprintf (&remotecmd, "%s%s", remotecmd, optarg); 285 xasprintf (&remotecmd, "%s%s", remotecmd, optarg);
286 break; 286 break;
287 case 'S': /* skip n (or all) lines on stdout */ 287 case 'S': /* skip n (or all) lines on stdout */
288 if (optarg == NULL) 288 if (optarg == NULL)
@@ -328,13 +328,13 @@ process_arguments (int argc, char **argv)
328 if (strlen(remotecmd) == 0) { 328 if (strlen(remotecmd) == 0) {
329 for (; c < argc; c++) 329 for (; c < argc; c++)
330 if (strlen(remotecmd) > 0) 330 if (strlen(remotecmd) > 0)
331 asprintf (&remotecmd, "%s %s", remotecmd, argv[c]); 331 xasprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
332 else 332 else
333 asprintf (&remotecmd, "%s", argv[c]); 333 xasprintf (&remotecmd, "%s", argv[c]);
334 } 334 }
335 335
336 if (commands > 1 || passive) 336 if (commands > 1 || passive)
337 asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd); 337 xasprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
338 338
339 if (remotecmd == NULL || strlen (remotecmd) <= 1) 339 if (remotecmd == NULL || strlen (remotecmd) <= 1)
340 usage_va(_("No remotecmd")); 340 usage_va(_("No remotecmd"));
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 06f59c80..893e0a14 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -87,7 +87,7 @@ main (int argc, char **argv)
87 usage_va(_("Could not parse arguments")); 87 usage_va(_("Could not parse arguments"));
88 88
89 /* get the command to run */ 89 /* get the command to run */
90 asprintf (&command_line, "%s @%s -p %d %s -t %s %s", 90 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s",
91 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args); 91 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args);
92 92
93 alarm (timeout_interval); 93 alarm (timeout_interval);
@@ -306,7 +306,7 @@ print_help (void)
306{ 306{
307 char *myport; 307 char *myport;
308 308
309 asprintf (&myport, "%d", DEFAULT_PORT); 309 xasprintf (&myport, "%d", DEFAULT_PORT);
310 310
311 print_revision (progname, NP_VERSION); 311 print_revision (progname, NP_VERSION);
312 312
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f8897647..f8e913e1 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -320,7 +320,7 @@ main (int argc, char **argv)
320 } 320 }
321 321
322 /* Nb: *_high_tide are unset when == UINT_MAX */ 322 /* Nb: *_high_tide are unset when == UINT_MAX */
323 asprintf (&perf, "%s %s", perf, 323 xasprintf (&perf, "%s %s", perf,
324 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 324 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
325 path->dused_units, units, 325 path->dused_units, units,
326 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide, 326 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide,
@@ -331,20 +331,20 @@ main (int argc, char **argv)
331 if (disk_result==STATE_OK && erronly && !verbose) 331 if (disk_result==STATE_OK && erronly && !verbose)
332 continue; 332 continue;
333 333
334 asprintf (&output, "%s %s %.0f %s (%.0f%%", 334 xasprintf (&output, "%s %s %.0f %s (%.0f%%",
335 output, 335 output,
336 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 336 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
337 path->dfree_units, 337 path->dfree_units,
338 units, 338 units,
339 path->dfree_pct); 339 path->dfree_pct);
340 if (path->dused_inodes_percent < 0) { 340 if (path->dused_inodes_percent < 0) {
341 asprintf(&output, "%s inode=-);", output); 341 xasprintf(&output, "%s inode=-);", output);
342 } else { 342 } else {
343 asprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent ); 343 xasprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
344 } 344 }
345 345
346 /* TODO: Need to do a similar debug line 346 /* TODO: Need to do a similar debug line
347 asprintf (&details, _("%s\n\ 347 xasprintf (&details, _("%s\n\
348%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"), 348%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
349 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct, 349 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
350 me->me_devname, me->me_type, me->me_mountdir, 350 me->me_devname, me->me_type, me->me_mountdir,
@@ -356,7 +356,7 @@ main (int argc, char **argv)
356 } 356 }
357 357
358 if (verbose >= 2) 358 if (verbose >= 2)
359 asprintf (&output, "%s%s", output, details); 359 xasprintf (&output, "%s%s", output, details);
360 360
361 361
362 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf); 362 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
@@ -473,13 +473,13 @@ process_arguments (int argc, char **argv)
473 if (*optarg == '@') { 473 if (*optarg == '@') {
474 warn_freespace_percent = optarg; 474 warn_freespace_percent = optarg;
475 } else { 475 } else {
476 asprintf(&warn_freespace_percent, "@%s", optarg); 476 xasprintf(&warn_freespace_percent, "@%s", optarg);
477 } 477 }
478 } else { 478 } else {
479 if (*optarg == '@') { 479 if (*optarg == '@') {
480 warn_freespace_units = optarg; 480 warn_freespace_units = optarg;
481 } else { 481 } else {
482 asprintf(&warn_freespace_units, "@%s", optarg); 482 xasprintf(&warn_freespace_units, "@%s", optarg);
483 } 483 }
484 } 484 }
485 break; 485 break;
@@ -494,13 +494,13 @@ process_arguments (int argc, char **argv)
494 if (*optarg == '@') { 494 if (*optarg == '@') {
495 crit_freespace_percent = optarg; 495 crit_freespace_percent = optarg;
496 } else { 496 } else {
497 asprintf(&crit_freespace_percent, "@%s", optarg); 497 xasprintf(&crit_freespace_percent, "@%s", optarg);
498 } 498 }
499 } else { 499 } else {
500 if (*optarg == '@') { 500 if (*optarg == '@') {
501 crit_freespace_units = optarg; 501 crit_freespace_units = optarg;
502 } else { 502 } else {
503 asprintf(&crit_freespace_units, "@%s", optarg); 503 xasprintf(&crit_freespace_units, "@%s", optarg);
504 } 504 }
505 } 505 }
506 break; 506 break;
@@ -509,14 +509,14 @@ process_arguments (int argc, char **argv)
509 if (*optarg == '@') { 509 if (*optarg == '@') {
510 warn_freeinodes_percent = optarg; 510 warn_freeinodes_percent = optarg;
511 } else { 511 } else {
512 asprintf(&warn_freeinodes_percent, "@%s", optarg); 512 xasprintf(&warn_freeinodes_percent, "@%s", optarg);
513 } 513 }
514 break; 514 break;
515 case 'K': /* critical inode threshold */ 515 case 'K': /* critical inode threshold */
516 if (*optarg == '@') { 516 if (*optarg == '@') {
517 crit_freeinodes_percent = optarg; 517 crit_freeinodes_percent = optarg;
518 } else { 518 } else {
519 asprintf(&crit_freeinodes_percent, "@%s", optarg); 519 xasprintf(&crit_freeinodes_percent, "@%s", optarg);
520 } 520 }
521 break; 521 break;
522 case 'u': 522 case 'u':
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 73b560ca..91af730b 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -103,7 +103,7 @@ main (int argc, char **argv)
103 } 103 }
104 104
105 /* get the command to run */ 105 /* get the command to run */
106 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); 106 xasprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
107 107
108 alarm (timeout_interval); 108 alarm (timeout_interval);
109 gettimeofday (&tv, NULL); 109 gettimeofday (&tv, NULL);
@@ -208,19 +208,19 @@ main (int argc, char **argv)
208 for (i=0; i<expected_address_cnt; i++) { 208 for (i=0; i<expected_address_cnt; i++) {
209 /* check if we get a match and prepare an error string */ 209 /* check if we get a match and prepare an error string */
210 if (strcmp(address, expected_address[i]) == 0) result = STATE_OK; 210 if (strcmp(address, expected_address[i]) == 0) result = STATE_OK;
211 asprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]); 211 xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
212 } 212 }
213 if (result == STATE_CRITICAL) { 213 if (result == STATE_CRITICAL) {
214 /* Strip off last semicolon... */ 214 /* Strip off last semicolon... */
215 temp_buffer[strlen(temp_buffer)-2] = '\0'; 215 temp_buffer[strlen(temp_buffer)-2] = '\0';
216 asprintf(&msg, _("expected '%s' but got '%s'"), temp_buffer, address); 216 xasprintf(&msg, _("expected '%s' but got '%s'"), temp_buffer, address);
217 } 217 }
218 } 218 }
219 219
220 /* check if authoritative */ 220 /* check if authoritative */
221 if (result == STATE_OK && expect_authority && non_authoritative) { 221 if (result == STATE_OK && expect_authority && non_authoritative) {
222 result = STATE_CRITICAL; 222 result = STATE_CRITICAL;
223 asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address); 223 xasprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
224 } 224 }
225 225
226 microsec = deltime (tv); 226 microsec = deltime (tv);
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index dd3f86d1..675a547c 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -92,11 +92,11 @@ main (int argc, char **argv)
92 92
93 /* compose the command */ 93 /* compose the command */
94 if (target_timeout) 94 if (target_timeout)
95 asprintf(&option_string, "%s-t %d ", option_string, target_timeout); 95 xasprintf(&option_string, "%s-t %d ", option_string, target_timeout);
96 if (packet_interval) 96 if (packet_interval)
97 asprintf(&option_string, "%s-p %d ", option_string, packet_interval); 97 xasprintf(&option_string, "%s-p %d ", option_string, packet_interval);
98 98
99 asprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING, 99 xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING,
100 option_string, packet_size, packet_count, server); 100 option_string, packet_size, packet_count, server);
101 101
102 if (verbose) 102 if (verbose)
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 5496c4dc..89bb4b12 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -84,11 +84,11 @@ main (int argc, char **argv)
84 result = STATE_OK; 84 result = STATE_OK;
85 85
86 /* create the command line to execute */ 86 /* create the command line to execute */
87 asprintf (&command_line, "%s -raw %s -%s %s", 87 xasprintf (&command_line, "%s -raw %s -%s %s",
88 PATH_TO_QSTAT, QSTAT_DATA_DELIMITER, game_type, server_ip); 88 PATH_TO_QSTAT, QSTAT_DATA_DELIMITER, game_type, server_ip);
89 89
90 if (port) 90 if (port)
91 asprintf (&command_line, "%s:%-d", command_line, port); 91 xasprintf (&command_line, "%s:%-d", command_line, port);
92 92
93 if (verbose > 0) 93 if (verbose > 0)
94 printf ("%s\n", command_line); 94 printf ("%s\n", command_line);
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 51a0099a..60e922ed 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -227,7 +227,7 @@ main (int argc, char **argv)
227 227
228 /* might not be the problem, but most likely is. */ 228 /* might not be the problem, but most likely is. */
229 result = STATE_UNKNOWN ; 229 result = STATE_UNKNOWN ;
230 asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address ); 230 xasprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address );
231 231
232 } 232 }
233 233
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 703e3174..77a235e4 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -147,7 +147,7 @@ main (int argc, char **argv)
147 /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */ 147 /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */
148 server_url = strdup(HTTP_URL); 148 server_url = strdup(HTTP_URL);
149 server_url_length = strlen(server_url); 149 server_url_length = strlen(server_url);
150 asprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)", 150 xasprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)",
151 NP_VERSION, VERSION); 151 NP_VERSION, VERSION);
152 152
153 /* Parse extra opts if any */ 153 /* Parse extra opts if any */
@@ -265,7 +265,7 @@ process_arguments (int argc, char **argv)
265 warning_thresholds = optarg; 265 warning_thresholds = optarg;
266 break; 266 break;
267 case 'A': /* User Agent String */ 267 case 'A': /* User Agent String */
268 asprintf (&user_agent, "User-Agent: %s", optarg); 268 xasprintf (&user_agent, "User-Agent: %s", optarg);
269 break; 269 break;
270 case 'k': /* Additional headers */ 270 case 'k': /* Additional headers */
271 if (http_opt_headers_count == 0) 271 if (http_opt_headers_count == 0)
@@ -273,7 +273,7 @@ process_arguments (int argc, char **argv)
273 else 273 else
274 http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count)); 274 http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count));
275 http_opt_headers[http_opt_headers_count - 1] = optarg; 275 http_opt_headers[http_opt_headers_count - 1] = optarg;
276 /* asprintf (&http_opt_headers, "%s", optarg); */ 276 /* xasprintf (&http_opt_headers, "%s", optarg); */
277 break; 277 break;
278 case 'L': /* show html link */ 278 case 'L': /* show html link */
279 display_html = TRUE; 279 display_html = TRUE;
@@ -394,7 +394,7 @@ process_arguments (int argc, char **argv)
394 server_expect_yn = 1; 394 server_expect_yn = 1;
395 break; 395 break;
396 case 'T': /* Content-type */ 396 case 'T': /* Content-type */
397 asprintf (&http_content_type, "%s", optarg); 397 xasprintf (&http_content_type, "%s", optarg);
398 break; 398 break;
399 case 'l': /* linespan */ 399 case 'l': /* linespan */
400 cflags &= ~REG_NEWLINE; 400 cflags &= ~REG_NEWLINE;
@@ -690,31 +690,31 @@ check_document_dates (const char *headers, char **msg)
690 690
691 /* Done parsing the body. Now check the dates we (hopefully) parsed. */ 691 /* Done parsing the body. Now check the dates we (hopefully) parsed. */
692 if (!server_date || !*server_date) { 692 if (!server_date || !*server_date) {
693 asprintf (msg, _("%sServer date unknown, "), *msg); 693 xasprintf (msg, _("%sServer date unknown, "), *msg);
694 date_result = max_state_alt(STATE_UNKNOWN, date_result); 694 date_result = max_state_alt(STATE_UNKNOWN, date_result);
695 } else if (!document_date || !*document_date) { 695 } else if (!document_date || !*document_date) {
696 asprintf (msg, _("%sDocument modification date unknown, "), *msg); 696 xasprintf (msg, _("%sDocument modification date unknown, "), *msg);
697 date_result = max_state_alt(STATE_CRITICAL, date_result); 697 date_result = max_state_alt(STATE_CRITICAL, date_result);
698 } else { 698 } else {
699 time_t srv_data = parse_time_string (server_date); 699 time_t srv_data = parse_time_string (server_date);
700 time_t doc_data = parse_time_string (document_date); 700 time_t doc_data = parse_time_string (document_date);
701 701
702 if (srv_data <= 0) { 702 if (srv_data <= 0) {
703 asprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); 703 xasprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
704 date_result = max_state_alt(STATE_CRITICAL, date_result); 704 date_result = max_state_alt(STATE_CRITICAL, date_result);
705 } else if (doc_data <= 0) { 705 } else if (doc_data <= 0) {
706 asprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date); 706 xasprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
707 date_result = max_state_alt(STATE_CRITICAL, date_result); 707 date_result = max_state_alt(STATE_CRITICAL, date_result);
708 } else if (doc_data > srv_data + 30) { 708 } else if (doc_data > srv_data + 30) {
709 asprintf (msg, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data); 709 xasprintf (msg, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
710 date_result = max_state_alt(STATE_CRITICAL, date_result); 710 date_result = max_state_alt(STATE_CRITICAL, date_result);
711 } else if (doc_data < srv_data - maximum_age) { 711 } else if (doc_data < srv_data - maximum_age) {
712 int n = (srv_data - doc_data); 712 int n = (srv_data - doc_data);
713 if (n > (60 * 60 * 24 * 2)) { 713 if (n > (60 * 60 * 24 * 2)) {
714 asprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24)); 714 xasprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
715 date_result = max_state_alt(STATE_CRITICAL, date_result); 715 date_result = max_state_alt(STATE_CRITICAL, date_result);
716 } else { 716 } else {
717 asprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60); 717 xasprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
718 date_result = max_state_alt(STATE_CRITICAL, date_result); 718 date_result = max_state_alt(STATE_CRITICAL, date_result);
719 } 719 }
720 } 720 }
@@ -831,10 +831,10 @@ check_http (void)
831 } 831 }
832#endif /* HAVE_SSL */ 832#endif /* HAVE_SSL */
833 833
834 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 834 xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
835 835
836 /* tell HTTP/1.1 servers not to keep the connection alive */ 836 /* tell HTTP/1.1 servers not to keep the connection alive */
837 asprintf (&buf, "%sConnection: close\r\n", buf); 837 xasprintf (&buf, "%sConnection: close\r\n", buf);
838 838
839 /* optionally send the host header info */ 839 /* optionally send the host header info */
840 if (host_name) { 840 if (host_name) {
@@ -845,16 +845,16 @@ check_http (void)
845 */ 845 */
846 if ((use_ssl == FALSE && server_port == HTTP_PORT) || 846 if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
847 (use_ssl == TRUE && server_port == HTTPS_PORT)) 847 (use_ssl == TRUE && server_port == HTTPS_PORT))
848 asprintf (&buf, "%sHost: %s\r\n", buf, host_name); 848 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
849 else 849 else
850 asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); 850 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
851 } 851 }
852 852
853 /* optionally send any other header tag */ 853 /* optionally send any other header tag */
854 if (http_opt_headers_count) { 854 if (http_opt_headers_count) {
855 for (i = 0; i < http_opt_headers_count ; i++) { 855 for (i = 0; i < http_opt_headers_count ; i++) {
856 for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) 856 for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER)))
857 asprintf (&buf, "%s%s\r\n", buf, pos); 857 xasprintf (&buf, "%s%s\r\n", buf, pos);
858 } 858 }
859 /* This cannot be free'd here because a redirection will then try to access this and segfault */ 859 /* This cannot be free'd here because a redirection will then try to access this and segfault */
860 /* Covered in a testcase in tests/check_http.t */ 860 /* Covered in a testcase in tests/check_http.t */
@@ -864,29 +864,29 @@ check_http (void)
864 /* optionally send the authentication info */ 864 /* optionally send the authentication info */
865 if (strlen(user_auth)) { 865 if (strlen(user_auth)) {
866 base64_encode_alloc (user_auth, strlen (user_auth), &auth); 866 base64_encode_alloc (user_auth, strlen (user_auth), &auth);
867 asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); 867 xasprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth);
868 } 868 }
869 869
870 /* optionally send the proxy authentication info */ 870 /* optionally send the proxy authentication info */
871 if (strlen(proxy_auth)) { 871 if (strlen(proxy_auth)) {
872 base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); 872 base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth);
873 asprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); 873 xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
874 } 874 }
875 875
876 /* either send http POST data (any data, not only POST)*/ 876 /* either send http POST data (any data, not only POST)*/
877 if (http_post_data) { 877 if (http_post_data) {
878 if (http_content_type) { 878 if (http_content_type) {
879 asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); 879 xasprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type);
880 } else { 880 } else {
881 asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); 881 xasprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
882 } 882 }
883 883
884 asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); 884 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
885 asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 885 xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
886 } 886 }
887 else { 887 else {
888 /* or just a newline so the server knows we're done with the request */ 888 /* or just a newline so the server knows we're done with the request */
889 asprintf (&buf, "%s%s", buf, CRLF); 889 xasprintf (&buf, "%s%s", buf, CRLF);
890 } 890 }
891 891
892 if (verbose) printf ("%s\n", buf); 892 if (verbose) printf ("%s\n", buf);
@@ -896,7 +896,7 @@ check_http (void)
896 full_page = strdup(""); 896 full_page = strdup("");
897 while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) { 897 while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) {
898 buffer[i] = '\0'; 898 buffer[i] = '\0';
899 asprintf (&full_page_new, "%s%s", full_page, buffer); 899 xasprintf (&full_page_new, "%s%s", full_page, buffer);
900 free (full_page); 900 free (full_page);
901 full_page = full_page_new; 901 full_page = full_page_new;
902 pagesize += i; 902 pagesize += i;
@@ -981,11 +981,11 @@ check_http (void)
981 /* make sure the status line matches the response we are looking for */ 981 /* make sure the status line matches the response we are looking for */
982 if (!expected_statuscode (status_line, server_expect)) { 982 if (!expected_statuscode (status_line, server_expect)) {
983 if (server_port == HTTP_PORT) 983 if (server_port == HTTP_PORT)
984 asprintf (&msg, 984 xasprintf (&msg,
985 _("Invalid HTTP response received from host: %s\n"), 985 _("Invalid HTTP response received from host: %s\n"),
986 status_line); 986 status_line);
987 else 987 else
988 asprintf (&msg, 988 xasprintf (&msg,
989 _("Invalid HTTP response received from host on port %d: %s\n"), 989 _("Invalid HTTP response received from host on port %d: %s\n"),
990 server_port, status_line); 990 server_port, status_line);
991 die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); 991 die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
@@ -994,7 +994,7 @@ check_http (void)
994 /* Bypass normal status line check if server_expect was set by user and not default */ 994 /* Bypass normal status line check if server_expect was set by user and not default */
995 /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */ 995 /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */
996 if ( server_expect_yn ) { 996 if ( server_expect_yn ) {
997 asprintf (&msg, 997 xasprintf (&msg,
998 _("Status line output matched \"%s\" - "), server_expect); 998 _("Status line output matched \"%s\" - "), server_expect);
999 if (verbose) 999 if (verbose)
1000 printf ("%s\n",msg); 1000 printf ("%s\n",msg);
@@ -1017,12 +1017,12 @@ check_http (void)
1017 } 1017 }
1018 /* server errors result in a critical state */ 1018 /* server errors result in a critical state */
1019 else if (http_status >= 500) { 1019 else if (http_status >= 500) {
1020 asprintf (&msg, _("%s - "), status_line); 1020 xasprintf (&msg, _("%s - "), status_line);
1021 result = STATE_CRITICAL; 1021 result = STATE_CRITICAL;
1022 } 1022 }
1023 /* client errors result in a warning state */ 1023 /* client errors result in a warning state */
1024 else if (http_status >= 400) { 1024 else if (http_status >= 400) {
1025 asprintf (&msg, _("%s - "), status_line); 1025 xasprintf (&msg, _("%s - "), status_line);
1026 result = max_state_alt(STATE_WARNING, result); 1026 result = max_state_alt(STATE_WARNING, result);
1027 } 1027 }
1028 /* check redirected page if specified */ 1028 /* check redirected page if specified */
@@ -1032,11 +1032,11 @@ check_http (void)
1032 redir (header, status_line); 1032 redir (header, status_line);
1033 else 1033 else
1034 result = max_state_alt(onredirect, result); 1034 result = max_state_alt(onredirect, result);
1035 asprintf (&msg, _("%s - "), status_line); 1035 xasprintf (&msg, _("%s - "), status_line);
1036 } /* end if (http_status >= 300) */ 1036 } /* end if (http_status >= 300) */
1037 else { 1037 else {
1038 /* Print OK status anyway */ 1038 /* Print OK status anyway */
1039 asprintf (&msg, _("%s - "), status_line); 1039 xasprintf (&msg, _("%s - "), status_line);
1040 } 1040 }
1041 1041
1042 } /* end else (server_expect_yn) */ 1042 } /* end else (server_expect_yn) */
@@ -1056,7 +1056,7 @@ check_http (void)
1056 if(output_string_search[sizeof(output_string_search)-1]!='\0') { 1056 if(output_string_search[sizeof(output_string_search)-1]!='\0') {
1057 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); 1057 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
1058 } 1058 }
1059 asprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1059 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
1060 result = STATE_CRITICAL; 1060 result = STATE_CRITICAL;
1061 } 1061 }
1062 } 1062 }
@@ -1069,15 +1069,15 @@ check_http (void)
1069 } 1069 }
1070 else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { 1070 else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) {
1071 if (invert_regex == 0) 1071 if (invert_regex == 0)
1072 asprintf (&msg, _("%spattern not found, "), msg); 1072 xasprintf (&msg, _("%spattern not found, "), msg);
1073 else 1073 else
1074 asprintf (&msg, _("%spattern found, "), msg); 1074 xasprintf (&msg, _("%spattern found, "), msg);
1075 result = STATE_CRITICAL; 1075 result = STATE_CRITICAL;
1076 } 1076 }
1077 else { 1077 else {
1078 /* FIXME: Shouldn't that be UNKNOWN? */ 1078 /* FIXME: Shouldn't that be UNKNOWN? */
1079 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 1079 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
1080 asprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf); 1080 xasprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf);
1081 result = STATE_CRITICAL; 1081 result = STATE_CRITICAL;
1082 } 1082 }
1083 } 1083 }
@@ -1093,10 +1093,10 @@ check_http (void)
1093 */ 1093 */
1094 page_len = pagesize; 1094 page_len = pagesize;
1095 if ((max_page_len > 0) && (page_len > max_page_len)) { 1095 if ((max_page_len > 0) && (page_len > max_page_len)) {
1096 asprintf (&msg, _("%spage size %d too large, "), msg, page_len); 1096 xasprintf (&msg, _("%spage size %d too large, "), msg, page_len);
1097 result = max_state_alt(STATE_WARNING, result); 1097 result = max_state_alt(STATE_WARNING, result);
1098 } else if ((min_page_len > 0) && (page_len < min_page_len)) { 1098 } else if ((min_page_len > 0) && (page_len < min_page_len)) {
1099 asprintf (&msg, _("%spage size %d too small, "), msg, page_len); 1099 xasprintf (&msg, _("%spage size %d too small, "), msg, page_len);
1100 result = max_state_alt(STATE_WARNING, result); 1100 result = max_state_alt(STATE_WARNING, result);
1101 } 1101 }
1102 1102
@@ -1107,7 +1107,7 @@ check_http (void)
1107 msg[strlen(msg)-3] = '\0'; 1107 msg[strlen(msg)-3] = '\0';
1108 1108
1109 /* check elapsed time */ 1109 /* check elapsed time */
1110 asprintf (&msg, 1110 xasprintf (&msg,
1111 _("%s - %d bytes in %.3f second response time %s|%s %s"), 1111 _("%s - %d bytes in %.3f second response time %s|%s %s"),
1112 msg, page_len, elapsed_time, 1112 msg, page_len, elapsed_time,
1113 (display_html ? "</A>" : ""), 1113 (display_html ? "</A>" : ""),
@@ -1214,7 +1214,7 @@ redir (char *pos, char *status_line)
1214 if ((url[0] != '/')) { 1214 if ((url[0] != '/')) {
1215 if ((x = strrchr(server_url, '/'))) 1215 if ((x = strrchr(server_url, '/')))
1216 *x = '\0'; 1216 *x = '\0';
1217 asprintf (&url, "%s/%s", server_url, url); 1217 xasprintf (&url, "%s/%s", server_url, url);
1218 } 1218 }
1219 i = server_port; 1219 i = server_port;
1220 strcpy (type, server_type); 1220 strcpy (type, server_type);
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index f83f1397..65db8517 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -99,7 +99,7 @@ main (int argc, char *argv[])
99 textdomain (PACKAGE); 99 textdomain (PACKAGE);
100 100
101 if (strstr(argv[0],"check_ldaps")) { 101 if (strstr(argv[0],"check_ldaps")) {
102 asprintf (&progname, "check_ldaps"); 102 xasprintf (&progname, "check_ldaps");
103 } 103 }
104 104
105 /* Parse extra opts if any */ 105 /* Parse extra opts if any */
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
145#endif 145#endif
146 146
147 if (ld_port == LDAPS_PORT || ssl_on_connect) { 147 if (ld_port == LDAPS_PORT || ssl_on_connect) {
148 asprintf (&SERVICE, "LDAPS"); 148 xasprintf (&SERVICE, "LDAPS");
149#if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS) 149#if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS)
150 /* ldaps: set option tls */ 150 /* ldaps: set option tls */
151 tls = LDAP_OPT_X_TLS_HARD; 151 tls = LDAP_OPT_X_TLS_HARD;
@@ -162,7 +162,7 @@ main (int argc, char *argv[])
162 return STATE_CRITICAL; 162 return STATE_CRITICAL;
163#endif /* LDAP_OPT_X_TLS */ 163#endif /* LDAP_OPT_X_TLS */
164 } else if (starttls) { 164 } else if (starttls) {
165 asprintf (&SERVICE, "LDAP-TLS"); 165 xasprintf (&SERVICE, "LDAP-TLS");
166#if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S) 166#if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S)
167 /* ldap with startTLS: set option version */ 167 /* ldap with startTLS: set option version */
168 if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS ) 168 if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS )
@@ -389,7 +389,7 @@ void
389print_help (void) 389print_help (void)
390{ 390{
391 char *myport; 391 char *myport;
392 asprintf (&myport, "%d", DEFAULT_PORT); 392 xasprintf (&myport, "%d", DEFAULT_PORT);
393 393
394 print_revision (progname, NP_VERSION); 394 print_revision (progname, NP_VERSION);
395 395
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 1bdb06aa..780ffffe 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -186,7 +186,7 @@ main (int argc, char **argv)
186 /* we got this far, so assume OK until we've measured */ 186 /* we got this far, so assume OK until we've measured */
187 result = STATE_OK; 187 result = STATE_OK;
188 188
189 asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); 189 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
190 190
191 for(i = 0; i < 3; i++) { 191 for(i = 0; i < 3; i++) {
192 if(la[i] > cload[i]) { 192 if(la[i] > cload[i]) {
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index 4fd9bc0a..a8226514 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -191,7 +191,7 @@ main (int argc, char **argv)
191 result = STATE_WARNING; 191 result = STATE_WARNING;
192 } 192 }
193 193
194 asprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"), 194 xasprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"),
195 (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, 195 (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate,
196 incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), 196 incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"),
197 adjusted_outgoing_rate, outgoing_speed_rating, 197 adjusted_outgoing_rate, outgoing_speed_rating,
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index d9b4e537..4fbdc2b9 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -369,7 +369,7 @@ void
369print_help (void) 369print_help (void)
370{ 370{
371 char *myport; 371 char *myport;
372 asprintf (&myport, "%d", MYSQL_PORT); 372 xasprintf (&myport, "%d", MYSQL_PORT);
373 373
374 print_revision (progname, NP_VERSION); 374 print_revision (progname, NP_VERSION);
375 375
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index cf9d8dfb..0bb83c3e 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -233,7 +233,7 @@ process_arguments (int argc, char **argv)
233 print_help (); 233 print_help ();
234 exit (STATE_OK); 234 exit (STATE_OK);
235 case 'q': 235 case 'q':
236 asprintf(&sql_query, "%s", optarg); 236 xasprintf(&sql_query, "%s", optarg);
237 break; 237 break;
238 case 'w': 238 case 'w':
239 warning = optarg; 239 warning = optarg;
@@ -277,7 +277,7 @@ void
277print_help (void) 277print_help (void)
278{ 278{
279 char *myport; 279 char *myport;
280 asprintf (&myport, "%d", MYSQL_PORT); 280 xasprintf (&myport, "%d", MYSQL_PORT);
281 281
282 print_revision (progname, NP_VERSION); 282 print_revision (progname, NP_VERSION);
283 283
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index 6485aa9a..c8cdbc02 100644
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
@@ -137,7 +137,7 @@ main (int argc, char **argv)
137 chld_out.line[i][pos+1] = 0x0; 137 chld_out.line[i][pos+1] = 0x0;
138 } 138 }
139 if ( cols >= expected_cols ) { 139 if ( cols >= expected_cols ) {
140 asprintf (&procargs, "%s", chld_out.line[i] + pos); 140 xasprintf (&procargs, "%s", chld_out.line[i] + pos);
141 strip (procargs); 141 strip (procargs);
142 142
143 /* Some ps return full pathname for command. This removes path */ 143 /* Some ps return full pathname for command. This removes path */
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 60806bb3..89c4d8d3 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -135,13 +135,13 @@ int main(int argc, char **argv){
135 135
136 case CHECK_CLIENTVERSION: 136 case CHECK_CLIENTVERSION:
137 137
138 asprintf(&send_buffer, "%s&1", req_password); 138 xasprintf(&send_buffer, "%s&1", req_password);
139 fetch_data (server_address, server_port, send_buffer); 139 fetch_data (server_address, server_port, send_buffer);
140 if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) { 140 if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) {
141 asprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list); 141 xasprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list);
142 return_code = STATE_WARNING; 142 return_code = STATE_WARNING;
143 } else { 143 } else {
144 asprintf (&output_message, "%s", recv_buffer); 144 xasprintf (&output_message, "%s", recv_buffer);
145 return_code = STATE_OK; 145 return_code = STATE_OK;
146 } 146 }
147 break; 147 break;
@@ -167,7 +167,7 @@ int main(int argc, char **argv){
167 lvalue_list[2+offset]<=(unsigned long)100) { 167 lvalue_list[2+offset]<=(unsigned long)100) {
168 168
169 /* Send request and retrieve data */ 169 /* Send request and retrieve data */
170 asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]); 170 xasprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
171 fetch_data (server_address, server_port, send_buffer); 171 fetch_data (server_address, server_port, send_buffer);
172 172
173 utilization=strtoul(recv_buffer,NULL,10); 173 utilization=strtoul(recv_buffer,NULL,10);
@@ -178,11 +178,11 @@ int main(int argc, char **argv){
178 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING) 178 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
179 return_code=STATE_WARNING; 179 return_code=STATE_WARNING;
180 180
181 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]); 181 xasprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
182 asprintf(&temp_string,"%s%s",temp_string,output_message); 182 xasprintf(&temp_string,"%s%s",temp_string,output_message);
183 asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization, 183 xasprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
184 lvalue_list[1+offset], lvalue_list[2+offset]); 184 lvalue_list[1+offset], lvalue_list[2+offset]);
185 asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata); 185 xasprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
186 offset+=3; /* move across the array */ 186 offset+=3; /* move across the array */
187 } 187 }
188 188
@@ -196,13 +196,13 @@ int main(int argc, char **argv){
196 196
197 case CHECK_UPTIME: 197 case CHECK_UPTIME:
198 198
199 asprintf(&send_buffer, "%s&3", req_password); 199 xasprintf(&send_buffer, "%s&3", req_password);
200 fetch_data (server_address, server_port, send_buffer); 200 fetch_data (server_address, server_port, send_buffer);
201 uptime=strtoul(recv_buffer,NULL,10); 201 uptime=strtoul(recv_buffer,NULL,10);
202 updays = uptime / 86400; 202 updays = uptime / 86400;
203 uphours = (uptime % 86400) / 3600; 203 uphours = (uptime % 86400) / 3600;
204 upminutes = ((uptime % 86400) % 3600) / 60; 204 upminutes = ((uptime % 86400) % 3600) / 60;
205 asprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes); 205 xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
206 if (check_critical_value==TRUE && uptime <= critical_value) 206 if (check_critical_value==TRUE && uptime <= critical_value)
207 return_code=STATE_CRITICAL; 207 return_code=STATE_CRITICAL;
208 else if (check_warning_value==TRUE && uptime <= warning_value) 208 else if (check_warning_value==TRUE && uptime <= warning_value)
@@ -218,7 +218,7 @@ int main(int argc, char **argv){
218 else if (strlen(value_list)!=1) 218 else if (strlen(value_list)!=1)
219 output_message = strdup (_("wrong -l argument")); 219 output_message = strdup (_("wrong -l argument"));
220 else { 220 else {
221 asprintf(&send_buffer,"%s&4&%s", req_password, value_list); 221 xasprintf(&send_buffer,"%s&4&%s", req_password, value_list);
222 fetch_data (server_address, server_port, send_buffer); 222 fetch_data (server_address, server_port, send_buffer);
223 fds=strtok(recv_buffer,"&"); 223 fds=strtok(recv_buffer,"&");
224 tds=strtok(NULL,"&"); 224 tds=strtok(NULL,"&");
@@ -232,10 +232,10 @@ int main(int argc, char **argv){
232 warning_used_space = ((float)warning_value / 100) * total_disk_space; 232 warning_used_space = ((float)warning_value / 100) * total_disk_space;
233 critical_used_space = ((float)critical_value / 100) * total_disk_space; 233 critical_used_space = ((float)critical_value / 100) * total_disk_space;
234 234
235 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), 235 xasprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
236 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, 236 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
237 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 237 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
238 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list, 238 xasprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
239 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, 239 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
240 critical_used_space / 1073741824, total_disk_space / 1073741824); 240 critical_used_space / 1073741824, total_disk_space / 1073741824);
241 241
@@ -262,7 +262,7 @@ int main(int argc, char **argv){
262 output_message = strdup (_("No service/process specified")); 262 output_message = strdup (_("No service/process specified"));
263 else { 263 else {
264 preparelist(value_list); /* replace , between services with & to send the request */ 264 preparelist(value_list); /* replace , between services with & to send the request */
265 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, 265 xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
266 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); 266 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
267 fetch_data (server_address, server_port, send_buffer); 267 fetch_data (server_address, server_port, send_buffer);
268 return_code=atoi(strtok(recv_buffer,"&")); 268 return_code=atoi(strtok(recv_buffer,"&"));
@@ -273,7 +273,7 @@ int main(int argc, char **argv){
273 273
274 case CHECK_MEMUSE: 274 case CHECK_MEMUSE:
275 275
276 asprintf(&send_buffer,"%s&7", req_password); 276 xasprintf(&send_buffer,"%s&7", req_password);
277 fetch_data (server_address, server_port, send_buffer); 277 fetch_data (server_address, server_port, send_buffer);
278 mem_commitLimit=atof(strtok(recv_buffer,"&")); 278 mem_commitLimit=atof(strtok(recv_buffer,"&"));
279 mem_commitByte=atof(strtok(NULL,"&")); 279 mem_commitByte=atof(strtok(NULL,"&"));
@@ -283,10 +283,10 @@ int main(int argc, char **argv){
283 283
284 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here, 284 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
285 which equals RAM + Pagefiles. */ 285 which equals RAM + Pagefiles. */
286 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 286 xasprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
287 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space, 287 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
288 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 288 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
289 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, 289 xasprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
290 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); 290 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
291 291
292 return_code=STATE_OK; 292 return_code=STATE_OK;
@@ -331,12 +331,12 @@ int main(int argc, char **argv){
331 strtok (value_list, "&"); /* burn the first parameters */ 331 strtok (value_list, "&"); /* burn the first parameters */
332 description = strtok (NULL, "&"); 332 description = strtok (NULL, "&");
333 counter_unit = strtok (NULL, "&"); 333 counter_unit = strtok (NULL, "&");
334 asprintf (&send_buffer, "%s&8&%s", req_password, value_list); 334 xasprintf (&send_buffer, "%s&8&%s", req_password, value_list);
335 fetch_data (server_address, server_port, send_buffer); 335 fetch_data (server_address, server_port, send_buffer);
336 counter_value = atof (recv_buffer); 336 counter_value = atof (recv_buffer);
337 337
338 if (description == NULL) 338 if (description == NULL)
339 asprintf (&output_message, "%.f", counter_value); 339 xasprintf (&output_message, "%.f", counter_value);
340 else if (isPercent) 340 else if (isPercent)
341 { 341 {
342 counter_unit = strdup ("%"); 342 counter_unit = strdup ("%");
@@ -371,13 +371,13 @@ int main(int argc, char **argv){
371 { 371 {
372 /* Let's format the output string, finally... */ 372 /* Let's format the output string, finally... */
373 if (strstr(description, "%") == NULL) { 373 if (strstr(description, "%") == NULL) {
374 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit); 374 xasprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
375 } else { 375 } else {
376 /* has formatting, will segv if wrong */ 376 /* has formatting, will segv if wrong */
377 asprintf (&output_message, description, counter_value); 377 xasprintf (&output_message, description, counter_value);
378 } 378 }
379 asprintf (&output_message, "%s |", output_message); 379 xasprintf (&output_message, "%s |", output_message);
380 asprintf (&output_message,"%s %s", output_message, 380 xasprintf (&output_message,"%s %s", output_message,
381 fperfdata (description, counter_value, 381 fperfdata (description, counter_value,
382 counter_unit, 1, warning_value, 1, critical_value, 382 counter_unit, 1, warning_value, 1, critical_value,
383 (!(isPercent) && (minval != NULL)), fminval, 383 (!(isPercent) && (minval != NULL)), fminval,
@@ -410,7 +410,7 @@ int main(int argc, char **argv){
410 output_message = strdup (_("No counter specified")); 410 output_message = strdup (_("No counter specified"));
411 else { 411 else {
412 preparelist(value_list); /* replace , between services with & to send the request */ 412 preparelist(value_list); /* replace , between services with & to send the request */
413 asprintf(&send_buffer,"%s&9&%s", req_password,value_list); 413 xasprintf(&send_buffer,"%s&9&%s", req_password,value_list);
414 fetch_data (server_address, server_port, send_buffer); 414 fetch_data (server_address, server_port, send_buffer);
415 age_in_minutes = atoi(strtok(recv_buffer,"&")); 415 age_in_minutes = atoi(strtok(recv_buffer,"&"));
416 description = strtok(NULL,"&"); 416 description = strtok(NULL,"&");
@@ -439,13 +439,13 @@ int main(int argc, char **argv){
439 if (value_list==NULL) 439 if (value_list==NULL)
440 output_message = strdup (_("No counter specified")); 440 output_message = strdup (_("No counter specified"));
441 else { 441 else {
442 asprintf(&send_buffer,"%s&10&%s", req_password,value_list); 442 xasprintf(&send_buffer,"%s&10&%s", req_password,value_list);
443 fetch_data (server_address, server_port, send_buffer); 443 fetch_data (server_address, server_port, send_buffer);
444 if (!strncmp(recv_buffer,"ERROR",5)) { 444 if (!strncmp(recv_buffer,"ERROR",5)) {
445 printf("NSClient - %s\n",recv_buffer); 445 printf("NSClient - %s\n",recv_buffer);
446 exit(STATE_UNKNOWN); 446 exit(STATE_UNKNOWN);
447 } 447 }
448 asprintf(&output_message,"%s",recv_buffer); 448 xasprintf(&output_message,"%s",recv_buffer);
449 return_code=STATE_OK; 449 return_code=STATE_OK;
450 } 450 }
451 break; 451 break;
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index ac89def7..76d19ba3 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -800,28 +800,28 @@ int main(int argc, char *argv[]){
800 800
801 switch (result) { 801 switch (result) {
802 case STATE_CRITICAL : 802 case STATE_CRITICAL :
803 asprintf(&result_line, _("NTP CRITICAL:")); 803 xasprintf(&result_line, _("NTP CRITICAL:"));
804 break; 804 break;
805 case STATE_WARNING : 805 case STATE_WARNING :
806 asprintf(&result_line, _("NTP WARNING:")); 806 xasprintf(&result_line, _("NTP WARNING:"));
807 break; 807 break;
808 case STATE_OK : 808 case STATE_OK :
809 asprintf(&result_line, _("NTP OK:")); 809 xasprintf(&result_line, _("NTP OK:"));
810 break; 810 break;
811 default : 811 default :
812 asprintf(&result_line, _("NTP UNKNOWN:")); 812 xasprintf(&result_line, _("NTP UNKNOWN:"));
813 break; 813 break;
814 } 814 }
815 if(offset_result == STATE_UNKNOWN){ 815 if(offset_result == STATE_UNKNOWN){
816 asprintf(&result_line, "%s %s", result_line, _("Offset unknown")); 816 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
817 asprintf(&perfdata_line, ""); 817 xasprintf(&perfdata_line, "");
818 } else { 818 } else {
819 asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); 819 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
820 asprintf(&perfdata_line, "%s", perfd_offset(offset)); 820 xasprintf(&perfdata_line, "%s", perfd_offset(offset));
821 } 821 }
822 if (do_jitter) { 822 if (do_jitter) {
823 asprintf(&result_line, "%s, jitter=%f", result_line, jitter); 823 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
824 asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); 824 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
825 } 825 }
826 printf("%s|%s\n", result_line, perfdata_line); 826 printf("%s|%s\n", result_line, perfdata_line);
827 827
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 62ac9aed..f0dd2d87 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -295,7 +295,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
295 /* If there's no sync.peer, query all candidates and use the best one */ 295 /* If there's no sync.peer, query all candidates and use the best one */
296 if (PEER_SEL(peers[i].status) >= min_peer_sel){ 296 if (PEER_SEL(peers[i].status) >= min_peer_sel){
297 if(verbose) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers[i].assoc)); 297 if(verbose) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers[i].assoc));
298 asprintf(&data, ""); 298 xasprintf(&data, "");
299 do{ 299 do{
300 setup_control_request(&req, OP_READVAR, 2); 300 setup_control_request(&req, OP_READVAR, 2);
301 req.assoc = peers[i].assoc; 301 req.assoc = peers[i].assoc;
@@ -318,7 +318,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
318 DBG(print_ntp_control_message(&req)); 318 DBG(print_ntp_control_message(&req));
319 319
320 if(!(req.op&REM_ERROR)) 320 if(!(req.op&REM_ERROR))
321 asprintf(&data, "%s%s", data, req.data); 321 xasprintf(&data, "%s%s", data, req.data);
322 } while(req.op&REM_MORE); 322 } while(req.op&REM_MORE);
323 323
324 if(req.op&REM_ERROR) { 324 if(req.op&REM_ERROR) {
@@ -603,41 +603,41 @@ int main(int argc, char *argv[]){
603 603
604 switch (result) { 604 switch (result) {
605 case STATE_CRITICAL : 605 case STATE_CRITICAL :
606 asprintf(&result_line, _("NTP CRITICAL:")); 606 xasprintf(&result_line, _("NTP CRITICAL:"));
607 break; 607 break;
608 case STATE_WARNING : 608 case STATE_WARNING :
609 asprintf(&result_line, _("NTP WARNING:")); 609 xasprintf(&result_line, _("NTP WARNING:"));
610 break; 610 break;
611 case STATE_OK : 611 case STATE_OK :
612 asprintf(&result_line, _("NTP OK:")); 612 xasprintf(&result_line, _("NTP OK:"));
613 break; 613 break;
614 default : 614 default :
615 asprintf(&result_line, _("NTP UNKNOWN:")); 615 xasprintf(&result_line, _("NTP UNKNOWN:"));
616 break; 616 break;
617 } 617 }
618 if(!syncsource_found) 618 if(!syncsource_found)
619 asprintf(&result_line, "%s %s,", result_line, _("Server not synchronized")); 619 xasprintf(&result_line, "%s %s,", result_line, _("Server not synchronized"));
620 else if(li_alarm) 620 else if(li_alarm)
621 asprintf(&result_line, "%s %s,", result_line, _("Server has the LI_ALARM bit set")); 621 xasprintf(&result_line, "%s %s,", result_line, _("Server has the LI_ALARM bit set"));
622 622
623 if(offset_result == STATE_UNKNOWN){ 623 if(offset_result == STATE_UNKNOWN){
624 asprintf(&result_line, "%s %s", result_line, _("Offset unknown")); 624 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
625 asprintf(&perfdata_line, ""); 625 xasprintf(&perfdata_line, "");
626 } else { 626 } else {
627 asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); 627 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
628 asprintf(&perfdata_line, "%s", perfd_offset(offset)); 628 xasprintf(&perfdata_line, "%s", perfd_offset(offset));
629 } 629 }
630 if (do_jitter) { 630 if (do_jitter) {
631 asprintf(&result_line, "%s, jitter=%f", result_line, jitter); 631 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
632 asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); 632 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
633 } 633 }
634 if (do_stratum) { 634 if (do_stratum) {
635 asprintf(&result_line, "%s, stratum=%i", result_line, stratum); 635 xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
636 asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); 636 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
637 } 637 }
638 if (do_truechimers) { 638 if (do_truechimers) {
639 asprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); 639 xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
640 asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); 640 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
641 } 641 }
642 printf("%s|%s\n", result_line, perfdata_line); 642 printf("%s|%s\n", result_line, perfdata_line);
643 643
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index f0f74b4e..d543d6b5 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -564,24 +564,24 @@ int main(int argc, char *argv[]){
564 564
565 switch (result) { 565 switch (result) {
566 case STATE_CRITICAL : 566 case STATE_CRITICAL :
567 asprintf(&result_line, _("NTP CRITICAL:")); 567 xasprintf(&result_line, _("NTP CRITICAL:"));
568 break; 568 break;
569 case STATE_WARNING : 569 case STATE_WARNING :
570 asprintf(&result_line, _("NTP WARNING:")); 570 xasprintf(&result_line, _("NTP WARNING:"));
571 break; 571 break;
572 case STATE_OK : 572 case STATE_OK :
573 asprintf(&result_line, _("NTP OK:")); 573 xasprintf(&result_line, _("NTP OK:"));
574 break; 574 break;
575 default : 575 default :
576 asprintf(&result_line, _("NTP UNKNOWN:")); 576 xasprintf(&result_line, _("NTP UNKNOWN:"));
577 break; 577 break;
578 } 578 }
579 if(offset_result == STATE_UNKNOWN){ 579 if(offset_result == STATE_UNKNOWN){
580 asprintf(&result_line, "%s %s", result_line, _("Offset unknown")); 580 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
581 asprintf(&perfdata_line, ""); 581 xasprintf(&perfdata_line, "");
582 } else { 582 } else {
583 asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); 583 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
584 asprintf(&perfdata_line, "%s", perfd_offset(offset)); 584 xasprintf(&perfdata_line, "%s", perfd_offset(offset));
585 } 585 }
586 printf("%s|%s\n", result_line, perfdata_line); 586 printf("%s|%s\n", result_line, perfdata_line);
587 587
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 81c55752..6ebe8f83 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -191,7 +191,7 @@ main(int argc, char **argv) {
191 netware_version = strdup(""); 191 netware_version = strdup("");
192 else { 192 else {
193 recv_buffer[strlen(recv_buffer)-1]=0; 193 recv_buffer[strlen(recv_buffer)-1]=0;
194 asprintf (&netware_version,_("NetWare %s: "),recv_buffer); 194 xasprintf (&netware_version,_("NetWare %s: "),recv_buffer);
195 } 195 }
196 } else 196 } else
197 netware_version = strdup(""); 197 netware_version = strdup("");
@@ -215,7 +215,7 @@ main(int argc, char **argv) {
215 close(sd); 215 close(sd);
216 my_tcp_connect (server_address, server_port, &sd); 216 my_tcp_connect (server_address, server_port, &sd);
217 217
218 asprintf (&send_buffer,"UTIL%s\r\n",temp_buffer); 218 xasprintf (&send_buffer,"UTIL%s\r\n",temp_buffer);
219 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 219 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
220 if (result!=STATE_OK) 220 if (result!=STATE_OK)
221 return result; 221 return result;
@@ -236,7 +236,7 @@ main(int argc, char **argv) {
236 else if (check_warning_value==TRUE && utilization >= warning_value) 236 else if (check_warning_value==TRUE && utilization >= warning_value)
237 result=STATE_WARNING; 237 result=STATE_WARNING;
238 238
239 asprintf (&output_message, 239 xasprintf (&output_message,
240 _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"), 240 _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"),
241 state_text(result), 241 state_text(result),
242 uptime, 242 uptime,
@@ -264,7 +264,7 @@ main(int argc, char **argv) {
264 else if (check_warning_value==TRUE && current_connections >= warning_value) 264 else if (check_warning_value==TRUE && current_connections >= warning_value)
265 result=STATE_WARNING; 265 result=STATE_WARNING;
266 266
267 asprintf (&output_message, 267 xasprintf (&output_message,
268 _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"), 268 _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"),
269 state_text(result), 269 state_text(result),
270 current_connections, 270 current_connections,
@@ -289,7 +289,7 @@ main(int argc, char **argv) {
289 else if (check_warning_value==TRUE && cache_hits <= warning_value) 289 else if (check_warning_value==TRUE && cache_hits <= warning_value)
290 result=STATE_WARNING; 290 result=STATE_WARNING;
291 291
292 asprintf (&output_message, 292 xasprintf (&output_message,
293 _("%s: Long term cache hits = %lu%%"), 293 _("%s: Long term cache hits = %lu%%"),
294 state_text(result), 294 state_text(result),
295 cache_hits); 295 cache_hits);
@@ -311,7 +311,7 @@ main(int argc, char **argv) {
311 else if (check_warning_value==TRUE && cache_buffers <= warning_value) 311 else if (check_warning_value==TRUE && cache_buffers <= warning_value)
312 result=STATE_WARNING; 312 result=STATE_WARNING;
313 313
314 asprintf (&output_message, 314 xasprintf (&output_message,
315 _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"), 315 _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"),
316 state_text(result), 316 state_text(result),
317 cache_buffers, 317 cache_buffers,
@@ -336,7 +336,7 @@ main(int argc, char **argv) {
336 else if (check_warning_value==TRUE && cache_buffers >= warning_value) 336 else if (check_warning_value==TRUE && cache_buffers >= warning_value)
337 result=STATE_WARNING; 337 result=STATE_WARNING;
338 338
339 asprintf (&output_message, 339 xasprintf (&output_message,
340 _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"), 340 _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"),
341 state_text(result), 341 state_text(result),
342 cache_buffers, 342 cache_buffers,
@@ -361,7 +361,7 @@ main(int argc, char **argv) {
361 else if (check_warning_value==TRUE && lru_time <= warning_value) 361 else if (check_warning_value==TRUE && lru_time <= warning_value)
362 result=STATE_WARNING; 362 result=STATE_WARNING;
363 363
364 asprintf (&output_message, 364 xasprintf (&output_message,
365 _("%s: LRU sitting time = %lu minutes"), 365 _("%s: LRU sitting time = %lu minutes"),
366 state_text(result), 366 state_text(result),
367 lru_time); 367 lru_time);
@@ -373,13 +373,13 @@ main(int argc, char **argv) {
373 close(sd); 373 close(sd);
374 my_tcp_connect (server_address, server_port, &sd); 374 my_tcp_connect (server_address, server_port, &sd);
375 375
376 asprintf (&send_buffer,"VKF%s\r\n",volume_name); 376 xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
377 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 377 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
378 if (result!=STATE_OK) 378 if (result!=STATE_OK)
379 return result; 379 return result;
380 380
381 if (!strcmp(recv_buffer,"-1\n")) { 381 if (!strcmp(recv_buffer,"-1\n")) {
382 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 382 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
383 result=STATE_CRITICAL; 383 result=STATE_CRITICAL;
384 } else { 384 } else {
385 free_disk_space=strtoul(recv_buffer,NULL,10); 385 free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -387,7 +387,7 @@ main(int argc, char **argv) {
387 result=STATE_CRITICAL; 387 result=STATE_CRITICAL;
388 else if (check_warning_value==TRUE && free_disk_space <= warning_value) 388 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
389 result=STATE_WARNING; 389 result=STATE_WARNING;
390 asprintf (&output_message, 390 xasprintf (&output_message,
391 _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"), 391 _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"),
392 (result==STATE_OK)?"":_("Only "), 392 (result==STATE_OK)?"":_("Only "),
393 free_disk_space, 393 free_disk_space,
@@ -401,13 +401,13 @@ main(int argc, char **argv) {
401 /* check MB free space on volume */ 401 /* check MB free space on volume */
402 } else if (vars_to_check==VMF) { 402 } else if (vars_to_check==VMF) {
403 403
404 asprintf (&send_buffer,"VMF%s\r\n",volume_name); 404 xasprintf (&send_buffer,"VMF%s\r\n",volume_name);
405 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 405 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
406 if (result!=STATE_OK) 406 if (result!=STATE_OK)
407 return result; 407 return result;
408 408
409 if (!strcmp(recv_buffer,"-1\n")) { 409 if (!strcmp(recv_buffer,"-1\n")) {
410 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 410 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
411 result=STATE_CRITICAL; 411 result=STATE_CRITICAL;
412 } else { 412 } else {
413 free_disk_space=strtoul(recv_buffer,NULL,10); 413 free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -415,7 +415,7 @@ main(int argc, char **argv) {
415 result=STATE_CRITICAL; 415 result=STATE_CRITICAL;
416 else if (check_warning_value==TRUE && free_disk_space <= warning_value) 416 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
417 result=STATE_WARNING; 417 result=STATE_WARNING;
418 asprintf (&output_message, 418 xasprintf (&output_message,
419 _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"), 419 _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"),
420 (result==STATE_OK)?"":_("Only "), 420 (result==STATE_OK)?"":_("Only "),
421 free_disk_space, 421 free_disk_space,
@@ -428,13 +428,13 @@ main(int argc, char **argv) {
428 /* check MB used space on volume */ 428 /* check MB used space on volume */
429 } else if (vars_to_check==VMU) { 429 } else if (vars_to_check==VMU) {
430 430
431 asprintf (&send_buffer,"VMU%s\r\n",volume_name); 431 xasprintf (&send_buffer,"VMU%s\r\n",volume_name);
432 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 432 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
433 if (result!=STATE_OK) 433 if (result!=STATE_OK)
434 return result; 434 return result;
435 435
436 if (!strcmp(recv_buffer,"-1\n")) { 436 if (!strcmp(recv_buffer,"-1\n")) {
437 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 437 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
438 result=STATE_CRITICAL; 438 result=STATE_CRITICAL;
439 } else { 439 } else {
440 free_disk_space=strtoul(recv_buffer,NULL,10); 440 free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -442,7 +442,7 @@ main(int argc, char **argv) {
442 result=STATE_CRITICAL; 442 result=STATE_CRITICAL;
443 else if (check_warning_value==TRUE && free_disk_space <= warning_value) 443 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
444 result=STATE_WARNING; 444 result=STATE_WARNING;
445 asprintf (&output_message, 445 xasprintf (&output_message,
446 _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"), 446 _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"),
447 (result==STATE_OK)?"":_("Only "), 447 (result==STATE_OK)?"":_("Only "),
448 free_disk_space, 448 free_disk_space,
@@ -460,14 +460,14 @@ main(int argc, char **argv) {
460 close(sd); 460 close(sd);
461 my_tcp_connect (server_address, server_port, &sd); 461 my_tcp_connect (server_address, server_port, &sd);
462 462
463 asprintf (&send_buffer,"VKF%s\r\n",volume_name); 463 xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
464 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 464 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
465 if (result!=STATE_OK) 465 if (result!=STATE_OK)
466 return result; 466 return result;
467 467
468 if (!strcmp(recv_buffer,"-1\n")) { 468 if (!strcmp(recv_buffer,"-1\n")) {
469 469
470 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 470 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
471 result=STATE_CRITICAL; 471 result=STATE_CRITICAL;
472 472
473 } else { 473 } else {
@@ -477,7 +477,7 @@ main(int argc, char **argv) {
477 close(sd); 477 close(sd);
478 my_tcp_connect (server_address, server_port, &sd); 478 my_tcp_connect (server_address, server_port, &sd);
479 479
480 asprintf (&send_buffer,"VKS%s\r\n",volume_name); 480 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
481 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 481 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
482 if (result!=STATE_OK) 482 if (result!=STATE_OK)
483 return result; 483 return result;
@@ -491,7 +491,7 @@ main(int argc, char **argv) {
491 result=STATE_WARNING; 491 result=STATE_WARNING;
492 free_disk_space/=1024; 492 free_disk_space/=1024;
493 total_disk_space/=1024; 493 total_disk_space/=1024;
494 asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"), 494 xasprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"),
495 free_disk_space, 495 free_disk_space,
496 percent_free_space, 496 percent_free_space,
497 volume_name, 497 volume_name,
@@ -525,7 +525,7 @@ main(int argc, char **argv) {
525 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 525 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
526 temp_buffer=strtok(recv_buffer,"\r\n"); 526 temp_buffer=strtok(recv_buffer,"\r\n");
527 527
528 asprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer); 528 xasprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer);
529 529
530 /* check to see if logins are enabled */ 530 /* check to see if logins are enabled */
531 } else if (vars_to_check==LOGINS) { 531 } else if (vars_to_check==LOGINS) {
@@ -542,13 +542,13 @@ main(int argc, char **argv) {
542 else 542 else
543 result=STATE_WARNING; 543 result=STATE_WARNING;
544 544
545 asprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled")); 545 xasprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled"));
546 546
547 547
548 /* check NRM Health Status Summary*/ 548 /* check NRM Health Status Summary*/
549 } else if (vars_to_check==NRMH) { 549 } else if (vars_to_check==NRMH) {
550 550
551 asprintf (&send_buffer,"NRMH\r\n"); 551 xasprintf (&send_buffer,"NRMH\r\n");
552 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 552 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
553 if (result!=STATE_OK) 553 if (result!=STATE_OK)
554 return result; 554 return result;
@@ -557,15 +557,15 @@ main(int argc, char **argv) {
557 557
558 if (nrm_health_status==2) { 558 if (nrm_health_status==2) {
559 result=STATE_OK; 559 result=STATE_OK;
560 asprintf (&output_message,_("CRITICAL - NRM Status is bad!")); 560 xasprintf (&output_message,_("CRITICAL - NRM Status is bad!"));
561 } 561 }
562 else { 562 else {
563 if (nrm_health_status==1) { 563 if (nrm_health_status==1) {
564 result=STATE_WARNING; 564 result=STATE_WARNING;
565 asprintf (&output_message,_("Warning - NRM Status is suspect!")); 565 xasprintf (&output_message,_("Warning - NRM Status is suspect!"));
566 } 566 }
567 567
568 asprintf (&output_message,_("OK - NRM Status is good!")); 568 xasprintf (&output_message,_("OK - NRM Status is good!"));
569 } 569 }
570 570
571 571
@@ -576,7 +576,7 @@ main(int argc, char **argv) {
576 close(sd); 576 close(sd);
577 my_tcp_connect (server_address, server_port, &sd); 577 my_tcp_connect (server_address, server_port, &sd);
578 578
579 asprintf (&send_buffer,"S15\r\n"); 579 xasprintf (&send_buffer,"S15\r\n");
580 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 580 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
581 if (result!=STATE_OK) 581 if (result!=STATE_OK)
582 return result; 582 return result;
@@ -586,7 +586,7 @@ main(int argc, char **argv) {
586 close(sd); 586 close(sd);
587 my_tcp_connect (server_address, server_port, &sd); 587 my_tcp_connect (server_address, server_port, &sd);
588 588
589 asprintf (&send_buffer,"S16\r\n"); 589 xasprintf (&send_buffer,"S16\r\n");
590 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 590 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
591 if (result!=STATE_OK) 591 if (result!=STATE_OK)
592 return result; 592 return result;
@@ -607,7 +607,7 @@ main(int argc, char **argv) {
607 result=STATE_WARNING; 607 result=STATE_WARNING;
608 } 608 }
609 609
610 asprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers); 610 xasprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers);
611 611
612 /* check SAP table entries */ 612 /* check SAP table entries */
613 } else if (vars_to_check==SAPENTRIES) { 613 } else if (vars_to_check==SAPENTRIES) {
@@ -616,9 +616,9 @@ main(int argc, char **argv) {
616 my_tcp_connect (server_address, server_port, &sd); 616 my_tcp_connect (server_address, server_port, &sd);
617 617
618 if (sap_number==-1) 618 if (sap_number==-1)
619 asprintf (&send_buffer,"S9\r\n"); 619 xasprintf (&send_buffer,"S9\r\n");
620 else 620 else
621 asprintf (&send_buffer,"S9.%d\r\n",sap_number); 621 xasprintf (&send_buffer,"S9.%d\r\n",sap_number);
622 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 622 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
623 if (result!=STATE_OK) 623 if (result!=STATE_OK)
624 return result; 624 return result;
@@ -631,9 +631,9 @@ main(int argc, char **argv) {
631 result=STATE_WARNING; 631 result=STATE_WARNING;
632 632
633 if (sap_number==-1) 633 if (sap_number==-1)
634 asprintf (&output_message,_("%lu entries in SAP table"),sap_entries); 634 xasprintf (&output_message,_("%lu entries in SAP table"),sap_entries);
635 else 635 else
636 asprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number); 636 xasprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number);
637 637
638 /* check KB purgeable space on volume */ 638 /* check KB purgeable space on volume */
639 } else if (vars_to_check==VKP) { 639 } else if (vars_to_check==VKP) {
@@ -641,13 +641,13 @@ main(int argc, char **argv) {
641 close(sd); 641 close(sd);
642 my_tcp_connect (server_address, server_port, &sd); 642 my_tcp_connect (server_address, server_port, &sd);
643 643
644 asprintf (&send_buffer,"VKP%s\r\n",volume_name); 644 xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
645 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 645 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
646 if (result!=STATE_OK) 646 if (result!=STATE_OK)
647 return result; 647 return result;
648 648
649 if (!strcmp(recv_buffer,"-1\n")) { 649 if (!strcmp(recv_buffer,"-1\n")) {
650 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 650 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
651 result=STATE_CRITICAL; 651 result=STATE_CRITICAL;
652 } else { 652 } else {
653 purgeable_disk_space=strtoul(recv_buffer,NULL,10); 653 purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -655,7 +655,7 @@ main(int argc, char **argv) {
655 result=STATE_CRITICAL; 655 result=STATE_CRITICAL;
656 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value) 656 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
657 result=STATE_WARNING; 657 result=STATE_WARNING;
658 asprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), 658 xasprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
659 (result==STATE_OK)?"":_("Only "), 659 (result==STATE_OK)?"":_("Only "),
660 purgeable_disk_space, 660 purgeable_disk_space,
661 volume_name, 661 volume_name,
@@ -667,13 +667,13 @@ main(int argc, char **argv) {
667 /* check MB purgeable space on volume */ 667 /* check MB purgeable space on volume */
668 } else if (vars_to_check==VMP) { 668 } else if (vars_to_check==VMP) {
669 669
670 asprintf (&send_buffer,"VMP%s\r\n",volume_name); 670 xasprintf (&send_buffer,"VMP%s\r\n",volume_name);
671 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 671 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
672 if (result!=STATE_OK) 672 if (result!=STATE_OK)
673 return result; 673 return result;
674 674
675 if (!strcmp(recv_buffer,"-1\n")) { 675 if (!strcmp(recv_buffer,"-1\n")) {
676 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 676 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
677 result=STATE_CRITICAL; 677 result=STATE_CRITICAL;
678 } else { 678 } else {
679 purgeable_disk_space=strtoul(recv_buffer,NULL,10); 679 purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -681,7 +681,7 @@ main(int argc, char **argv) {
681 result=STATE_CRITICAL; 681 result=STATE_CRITICAL;
682 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value) 682 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
683 result=STATE_WARNING; 683 result=STATE_WARNING;
684 asprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), 684 xasprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
685 (result==STATE_OK)?"":_("Only "), 685 (result==STATE_OK)?"":_("Only "),
686 purgeable_disk_space, 686 purgeable_disk_space,
687 volume_name, 687 volume_name,
@@ -697,14 +697,14 @@ main(int argc, char **argv) {
697 close(sd); 697 close(sd);
698 my_tcp_connect (server_address, server_port, &sd); 698 my_tcp_connect (server_address, server_port, &sd);
699 699
700 asprintf (&send_buffer,"VKP%s\r\n",volume_name); 700 xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
701 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 701 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
702 if (result!=STATE_OK) 702 if (result!=STATE_OK)
703 return result; 703 return result;
704 704
705 if (!strcmp(recv_buffer,"-1\n")) { 705 if (!strcmp(recv_buffer,"-1\n")) {
706 706
707 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 707 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
708 result=STATE_CRITICAL; 708 result=STATE_CRITICAL;
709 709
710 } else { 710 } else {
@@ -714,7 +714,7 @@ main(int argc, char **argv) {
714 close(sd); 714 close(sd);
715 my_tcp_connect (server_address, server_port, &sd); 715 my_tcp_connect (server_address, server_port, &sd);
716 716
717 asprintf (&send_buffer,"VKS%s\r\n",volume_name); 717 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
718 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 718 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
719 if (result!=STATE_OK) 719 if (result!=STATE_OK)
720 return result; 720 return result;
@@ -727,7 +727,7 @@ main(int argc, char **argv) {
727 else if (check_warning_value==TRUE && percent_purgeable_space >= warning_value) 727 else if (check_warning_value==TRUE && percent_purgeable_space >= warning_value)
728 result=STATE_WARNING; 728 result=STATE_WARNING;
729 purgeable_disk_space/=1024; 729 purgeable_disk_space/=1024;
730 asprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"), 730 xasprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"),
731 purgeable_disk_space, 731 purgeable_disk_space,
732 percent_purgeable_space, 732 percent_purgeable_space,
733 volume_name, 733 volume_name,
@@ -744,13 +744,13 @@ main(int argc, char **argv) {
744 close(sd); 744 close(sd);
745 my_tcp_connect (server_address, server_port, &sd); 745 my_tcp_connect (server_address, server_port, &sd);
746 746
747 asprintf (&send_buffer,"VKNP%s\r\n",volume_name); 747 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
748 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 748 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
749 if (result!=STATE_OK) 749 if (result!=STATE_OK)
750 return result; 750 return result;
751 751
752 if (!strcmp(recv_buffer,"-1\n")) { 752 if (!strcmp(recv_buffer,"-1\n")) {
753 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 753 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
754 result=STATE_CRITICAL; 754 result=STATE_CRITICAL;
755 } else { 755 } else {
756 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10); 756 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -758,7 +758,7 @@ main(int argc, char **argv) {
758 result=STATE_CRITICAL; 758 result=STATE_CRITICAL;
759 else if (check_warning_value==TRUE && non_purgeable_disk_space >= warning_value) 759 else if (check_warning_value==TRUE && non_purgeable_disk_space >= warning_value)
760 result=STATE_WARNING; 760 result=STATE_WARNING;
761 asprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name); 761 xasprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name);
762 } 762 }
763 763
764 /* check % not yet purgeable space on volume */ 764 /* check % not yet purgeable space on volume */
@@ -767,14 +767,14 @@ main(int argc, char **argv) {
767 close(sd); 767 close(sd);
768 my_tcp_connect (server_address, server_port, &sd); 768 my_tcp_connect (server_address, server_port, &sd);
769 769
770 asprintf (&send_buffer,"VKNP%s\r\n",volume_name); 770 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
771 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 771 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
772 if (result!=STATE_OK) 772 if (result!=STATE_OK)
773 return result; 773 return result;
774 774
775 if (!strcmp(recv_buffer,"-1\n")) { 775 if (!strcmp(recv_buffer,"-1\n")) {
776 776
777 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 777 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
778 result=STATE_CRITICAL; 778 result=STATE_CRITICAL;
779 779
780 } else { 780 } else {
@@ -784,7 +784,7 @@ main(int argc, char **argv) {
784 close(sd); 784 close(sd);
785 my_tcp_connect (server_address, server_port, &sd); 785 my_tcp_connect (server_address, server_port, &sd);
786 786
787 asprintf (&send_buffer,"VKS%s\r\n",volume_name); 787 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
788 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 788 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
789 if (result!=STATE_OK) 789 if (result!=STATE_OK)
790 return result; 790 return result;
@@ -797,7 +797,7 @@ main(int argc, char **argv) {
797 else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value) 797 else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
798 result=STATE_WARNING; 798 result=STATE_WARNING;
799 purgeable_disk_space/=1024; 799 purgeable_disk_space/=1024;
800 asprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name); 800 xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
801 } 801 }
802 802
803 /* check # of open files */ 803 /* check # of open files */
@@ -806,7 +806,7 @@ main(int argc, char **argv) {
806 close(sd); 806 close(sd);
807 my_tcp_connect (server_address, server_port, &sd); 807 my_tcp_connect (server_address, server_port, &sd);
808 808
809 asprintf (&send_buffer,"S18\r\n"); 809 xasprintf (&send_buffer,"S18\r\n");
810 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 810 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
811 if (result!=STATE_OK) 811 if (result!=STATE_OK)
812 return result; 812 return result;
@@ -818,7 +818,7 @@ main(int argc, char **argv) {
818 else if (check_warning_value==TRUE && open_files >= warning_value) 818 else if (check_warning_value==TRUE && open_files >= warning_value)
819 result=STATE_WARNING; 819 result=STATE_WARNING;
820 820
821 asprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"), 821 xasprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
822 open_files, 822 open_files,
823 open_files, 823 open_files,
824 warning_value, 824 warning_value,
@@ -831,7 +831,7 @@ main(int argc, char **argv) {
831 close(sd); 831 close(sd);
832 my_tcp_connect (server_address, server_port, &sd); 832 my_tcp_connect (server_address, server_port, &sd);
833 833
834 asprintf (&send_buffer,"S17\r\n"); 834 xasprintf (&send_buffer,"S17\r\n");
835 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 835 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
836 if (result!=STATE_OK) 836 if (result!=STATE_OK)
837 return result; 837 return result;
@@ -843,7 +843,7 @@ main(int argc, char **argv) {
843 else if (check_warning_value==TRUE && abended_threads >= warning_value) 843 else if (check_warning_value==TRUE && abended_threads >= warning_value)
844 result=STATE_WARNING; 844 result=STATE_WARNING;
845 845
846 asprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"), 846 xasprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"),
847 abended_threads, 847 abended_threads,
848 abended_threads, 848 abended_threads,
849 warning_value, 849 warning_value,
@@ -855,7 +855,7 @@ main(int argc, char **argv) {
855 close(sd); 855 close(sd);
856 my_tcp_connect (server_address, server_port, &sd); 856 my_tcp_connect (server_address, server_port, &sd);
857 857
858 asprintf (&send_buffer,"S20\r\n"); 858 xasprintf (&send_buffer,"S20\r\n");
859 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 859 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
860 if (result!=STATE_OK) 860 if (result!=STATE_OK)
861 return result; 861 return result;
@@ -865,7 +865,7 @@ main(int argc, char **argv) {
865 close(sd); 865 close(sd);
866 my_tcp_connect (server_address, server_port, &sd); 866 my_tcp_connect (server_address, server_port, &sd);
867 867
868 asprintf (&send_buffer,"S21\r\n"); 868 xasprintf (&send_buffer,"S21\r\n");
869 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 869 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
870 if (result!=STATE_OK) 870 if (result!=STATE_OK)
871 return result; 871 return result;
@@ -877,7 +877,7 @@ main(int argc, char **argv) {
877 else if (check_warning_value==TRUE && current_service_processes >= warning_value) 877 else if (check_warning_value==TRUE && current_service_processes >= warning_value)
878 result=STATE_WARNING; 878 result=STATE_WARNING;
879 879
880 asprintf (&output_message, 880 xasprintf (&output_message,
881 _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"), 881 _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"),
882 current_service_processes, 882 current_service_processes,
883 max_service_processes, 883 max_service_processes,
@@ -892,7 +892,7 @@ main(int argc, char **argv) {
892 close(sd); 892 close(sd);
893 my_tcp_connect (server_address, server_port, &sd); 893 my_tcp_connect (server_address, server_port, &sd);
894 894
895 asprintf (&send_buffer,"S22\r\n"); 895 xasprintf (&send_buffer,"S22\r\n");
896 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 896 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
897 if (result!=STATE_OK) 897 if (result!=STATE_OK)
898 return result; 898 return result;
@@ -901,10 +901,10 @@ main(int argc, char **argv) {
901 901
902 if (time_sync_status==0) { 902 if (time_sync_status==0) {
903 result=STATE_CRITICAL; 903 result=STATE_CRITICAL;
904 asprintf (&output_message,_("CRITICAL - Time not in sync with network!")); 904 xasprintf (&output_message,_("CRITICAL - Time not in sync with network!"));
905 } 905 }
906 else { 906 else {
907 asprintf (&output_message,_("OK - Time in sync with network!")); 907 xasprintf (&output_message,_("OK - Time in sync with network!"));
908 } 908 }
909 909
910 910
@@ -927,7 +927,7 @@ main(int argc, char **argv) {
927 result=STATE_CRITICAL; 927 result=STATE_CRITICAL;
928 else if (check_warning_value==TRUE && lru_time <= warning_value) 928 else if (check_warning_value==TRUE && lru_time <= warning_value)
929 result=STATE_WARNING; 929 result=STATE_WARNING;
930 asprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time); 930 xasprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time);
931 931
932 932
933 /* check % dirty cacheobuffers as a percentage of the total*/ 933 /* check % dirty cacheobuffers as a percentage of the total*/
@@ -946,7 +946,7 @@ main(int argc, char **argv) {
946 result=STATE_CRITICAL; 946 result=STATE_CRITICAL;
947 else if (check_warning_value==TRUE && dirty_cache_buffers <= warning_value) 947 else if (check_warning_value==TRUE && dirty_cache_buffers <= warning_value)
948 result=STATE_WARNING; 948 result=STATE_WARNING;
949 asprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"), 949 xasprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"),
950 dirty_cache_buffers, 950 dirty_cache_buffers,
951 dirty_cache_buffers, 951 dirty_cache_buffers,
952 warning_value, 952 warning_value,
@@ -968,7 +968,7 @@ main(int argc, char **argv) {
968 result=STATE_CRITICAL; 968 result=STATE_CRITICAL;
969 else if (check_warning_value==TRUE && total_cache_buffers <= warning_value) 969 else if (check_warning_value==TRUE && total_cache_buffers <= warning_value)
970 result=STATE_WARNING; 970 result=STATE_WARNING;
971 asprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"), 971 xasprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"),
972 total_cache_buffers, 972 total_cache_buffers,
973 total_cache_buffers, 973 total_cache_buffers,
974 warning_value, 974 warning_value,
@@ -979,21 +979,21 @@ main(int argc, char **argv) {
979 close(sd); 979 close(sd);
980 my_tcp_connect (server_address, server_port, &sd); 980 my_tcp_connect (server_address, server_port, &sd);
981 981
982 asprintf (&send_buffer,"S13\r\n"); 982 xasprintf (&send_buffer,"S13\r\n");
983 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 983 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
984 if (result!=STATE_OK) 984 if (result!=STATE_OK)
985 return result; 985 return result;
986 986
987 recv_buffer[strlen(recv_buffer)-1]=0; 987 recv_buffer[strlen(recv_buffer)-1]=0;
988 988
989 asprintf (&output_message,_("NDS Version %s"),recv_buffer); 989 xasprintf (&output_message,_("NDS Version %s"),recv_buffer);
990 990
991 } else if (vars_to_check==UPTIME) { 991 } else if (vars_to_check==UPTIME) {
992 992
993 close(sd); 993 close(sd);
994 my_tcp_connect (server_address, server_port, &sd); 994 my_tcp_connect (server_address, server_port, &sd);
995 995
996 asprintf (&send_buffer,"UPTIME\r\n"); 996 xasprintf (&send_buffer,"UPTIME\r\n");
997 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 997 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
998 if (result!=STATE_OK) 998 if (result!=STATE_OK)
999 return result; 999 return result;
@@ -1002,35 +1002,35 @@ main(int argc, char **argv) {
1002 recv_buffer[sizeof(recv_buffer)-1]=0; 1002 recv_buffer[sizeof(recv_buffer)-1]=0;
1003 recv_buffer[strlen(recv_buffer)-1]=0; 1003 recv_buffer[strlen(recv_buffer)-1]=0;
1004 1004
1005 asprintf (&output_message,_("Up %s"),recv_buffer); 1005 xasprintf (&output_message,_("Up %s"),recv_buffer);
1006 1006
1007 } else if (vars_to_check==NLM) { 1007 } else if (vars_to_check==NLM) {
1008 1008
1009 close(sd); 1009 close(sd);
1010 my_tcp_connect (server_address, server_port, &sd); 1010 my_tcp_connect (server_address, server_port, &sd);
1011 1011
1012 asprintf (&send_buffer,"S24:%s\r\n",nlm_name); 1012 xasprintf (&send_buffer,"S24:%s\r\n",nlm_name);
1013 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1013 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1014 if (result!=STATE_OK) 1014 if (result!=STATE_OK)
1015 return result; 1015 return result;
1016 1016
1017 recv_buffer[strlen(recv_buffer)-1]=0; 1017 recv_buffer[strlen(recv_buffer)-1]=0;
1018 if (strcmp(recv_buffer,"-1")) { 1018 if (strcmp(recv_buffer,"-1")) {
1019 asprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer); 1019 xasprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer);
1020 } else { 1020 } else {
1021 result=STATE_CRITICAL; 1021 result=STATE_CRITICAL;
1022 asprintf (&output_message,_("Module %s is not loaded"),nlm_name); 1022 xasprintf (&output_message,_("Module %s is not loaded"),nlm_name);
1023 1023
1024 } 1024 }
1025 } else if (vars_to_check==NRMP) { 1025 } else if (vars_to_check==NRMP) {
1026 1026
1027 asprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name); 1027 xasprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name);
1028 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1028 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1029 if (result!=STATE_OK) 1029 if (result!=STATE_OK)
1030 return result; 1030 return result;
1031 1031
1032 if (!strcmp(recv_buffer,"-1\n")) { 1032 if (!strcmp(recv_buffer,"-1\n")) {
1033 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name); 1033 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name);
1034 result=STATE_CRITICAL; 1034 result=STATE_CRITICAL;
1035 } else { 1035 } else {
1036 nrmp_value=strtoul(recv_buffer,NULL,10); 1036 nrmp_value=strtoul(recv_buffer,NULL,10);
@@ -1038,7 +1038,7 @@ main(int argc, char **argv) {
1038 result=STATE_CRITICAL; 1038 result=STATE_CRITICAL;
1039 else if (check_warning_value==TRUE && nrmp_value <= warning_value) 1039 else if (check_warning_value==TRUE && nrmp_value <= warning_value)
1040 result=STATE_WARNING; 1040 result=STATE_WARNING;
1041 asprintf (&output_message, 1041 xasprintf (&output_message,
1042 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1042 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1043 nrmp_name, 1043 nrmp_name,
1044 nrmp_value, 1044 nrmp_value,
@@ -1050,13 +1050,13 @@ main(int argc, char **argv) {
1050 1050
1051 } else if (vars_to_check==NRMM) { 1051 } else if (vars_to_check==NRMM) {
1052 1052
1053 asprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name); 1053 xasprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name);
1054 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1054 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1055 if (result!=STATE_OK) 1055 if (result!=STATE_OK)
1056 return result; 1056 return result;
1057 1057
1058 if (!strcmp(recv_buffer,"-1\n")) { 1058 if (!strcmp(recv_buffer,"-1\n")) {
1059 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name); 1059 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name);
1060 result=STATE_CRITICAL; 1060 result=STATE_CRITICAL;
1061 } else { 1061 } else {
1062 nrmm_value=strtoul(recv_buffer,NULL,10); 1062 nrmm_value=strtoul(recv_buffer,NULL,10);
@@ -1064,7 +1064,7 @@ main(int argc, char **argv) {
1064 result=STATE_CRITICAL; 1064 result=STATE_CRITICAL;
1065 else if (check_warning_value==TRUE && nrmm_value <= warning_value) 1065 else if (check_warning_value==TRUE && nrmm_value <= warning_value)
1066 result=STATE_WARNING; 1066 result=STATE_WARNING;
1067 asprintf (&output_message, 1067 xasprintf (&output_message,
1068 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1068 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1069 nrmm_name, 1069 nrmm_name,
1070 nrmm_value, 1070 nrmm_value,
@@ -1076,13 +1076,13 @@ main(int argc, char **argv) {
1076 1076
1077 } else if (vars_to_check==NRMS) { 1077 } else if (vars_to_check==NRMS) {
1078 1078
1079 asprintf (&send_buffer,"NRMS:%s\r\n",nrms_name); 1079 xasprintf (&send_buffer,"NRMS:%s\r\n",nrms_name);
1080 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1080 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1081 if (result!=STATE_OK) 1081 if (result!=STATE_OK)
1082 return result; 1082 return result;
1083 1083
1084 if (!strcmp(recv_buffer,"-1\n")) { 1084 if (!strcmp(recv_buffer,"-1\n")) {
1085 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name); 1085 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name);
1086 result=STATE_CRITICAL; 1086 result=STATE_CRITICAL;
1087 } else { 1087 } else {
1088 nrms_value=strtoul(recv_buffer,NULL,10); 1088 nrms_value=strtoul(recv_buffer,NULL,10);
@@ -1090,7 +1090,7 @@ main(int argc, char **argv) {
1090 result=STATE_CRITICAL; 1090 result=STATE_CRITICAL;
1091 else if (check_warning_value==TRUE && nrms_value >= warning_value) 1091 else if (check_warning_value==TRUE && nrms_value >= warning_value)
1092 result=STATE_WARNING; 1092 result=STATE_WARNING;
1093 asprintf (&output_message, 1093 xasprintf (&output_message,
1094 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1094 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1095 nrms_name, 1095 nrms_name,
1096 nrms_value, 1096 nrms_value,
@@ -1102,13 +1102,13 @@ main(int argc, char **argv) {
1102 1102
1103 } else if (vars_to_check==NSS1) { 1103 } else if (vars_to_check==NSS1) {
1104 1104
1105 asprintf (&send_buffer,"NSS1:%s\r\n",nss1_name); 1105 xasprintf (&send_buffer,"NSS1:%s\r\n",nss1_name);
1106 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1106 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1107 if (result!=STATE_OK) 1107 if (result!=STATE_OK)
1108 return result; 1108 return result;
1109 1109
1110 if (!strcmp(recv_buffer,"-1\n")) { 1110 if (!strcmp(recv_buffer,"-1\n")) {
1111 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name); 1111 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name);
1112 result=STATE_CRITICAL; 1112 result=STATE_CRITICAL;
1113 } else { 1113 } else {
1114 nss1_value=strtoul(recv_buffer,NULL,10); 1114 nss1_value=strtoul(recv_buffer,NULL,10);
@@ -1116,7 +1116,7 @@ main(int argc, char **argv) {
1116 result=STATE_CRITICAL; 1116 result=STATE_CRITICAL;
1117 else if (check_warning_value==TRUE && nss1_value >= warning_value) 1117 else if (check_warning_value==TRUE && nss1_value >= warning_value)
1118 result=STATE_WARNING; 1118 result=STATE_WARNING;
1119 asprintf (&output_message, 1119 xasprintf (&output_message,
1120 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1120 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1121 nss1_name, 1121 nss1_name,
1122 nss1_value, 1122 nss1_value,
@@ -1128,13 +1128,13 @@ main(int argc, char **argv) {
1128 1128
1129 } else if (vars_to_check==NSS2) { 1129 } else if (vars_to_check==NSS2) {
1130 1130
1131 asprintf (&send_buffer,"NSS2:%s\r\n",nss2_name); 1131 xasprintf (&send_buffer,"NSS2:%s\r\n",nss2_name);
1132 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1132 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1133 if (result!=STATE_OK) 1133 if (result!=STATE_OK)
1134 return result; 1134 return result;
1135 1135
1136 if (!strcmp(recv_buffer,"-1\n")) { 1136 if (!strcmp(recv_buffer,"-1\n")) {
1137 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name); 1137 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name);
1138 result=STATE_CRITICAL; 1138 result=STATE_CRITICAL;
1139 } else { 1139 } else {
1140 nss2_value=strtoul(recv_buffer,NULL,10); 1140 nss2_value=strtoul(recv_buffer,NULL,10);
@@ -1142,7 +1142,7 @@ main(int argc, char **argv) {
1142 result=STATE_CRITICAL; 1142 result=STATE_CRITICAL;
1143 else if (check_warning_value==TRUE && nss2_value >= warning_value) 1143 else if (check_warning_value==TRUE && nss2_value >= warning_value)
1144 result=STATE_WARNING; 1144 result=STATE_WARNING;
1145 asprintf (&output_message, 1145 xasprintf (&output_message,
1146 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1146 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1147 nss2_name, 1147 nss2_name,
1148 nss2_value, 1148 nss2_value,
@@ -1154,13 +1154,13 @@ main(int argc, char **argv) {
1154 1154
1155 } else if (vars_to_check==NSS3) { 1155 } else if (vars_to_check==NSS3) {
1156 1156
1157 asprintf (&send_buffer,"NSS3:%s\r\n",nss3_name); 1157 xasprintf (&send_buffer,"NSS3:%s\r\n",nss3_name);
1158 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1158 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1159 if (result!=STATE_OK) 1159 if (result!=STATE_OK)
1160 return result; 1160 return result;
1161 1161
1162 if (!strcmp(recv_buffer,"-1\n")) { 1162 if (!strcmp(recv_buffer,"-1\n")) {
1163 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name); 1163 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name);
1164 result=STATE_CRITICAL; 1164 result=STATE_CRITICAL;
1165 } else { 1165 } else {
1166 nss3_value=strtoul(recv_buffer,NULL,10); 1166 nss3_value=strtoul(recv_buffer,NULL,10);
@@ -1168,7 +1168,7 @@ main(int argc, char **argv) {
1168 result=STATE_CRITICAL; 1168 result=STATE_CRITICAL;
1169 else if (check_warning_value==TRUE && nss3_value >= warning_value) 1169 else if (check_warning_value==TRUE && nss3_value >= warning_value)
1170 result=STATE_WARNING; 1170 result=STATE_WARNING;
1171 asprintf (&output_message, 1171 xasprintf (&output_message,
1172 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1172 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1173 nss3_name, 1173 nss3_name,
1174 nss3_value, 1174 nss3_value,
@@ -1180,13 +1180,13 @@ main(int argc, char **argv) {
1180 1180
1181 } else if (vars_to_check==NSS4) { 1181 } else if (vars_to_check==NSS4) {
1182 1182
1183 asprintf (&send_buffer,"NSS4:%s\r\n",nss4_name); 1183 xasprintf (&send_buffer,"NSS4:%s\r\n",nss4_name);
1184 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1184 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1185 if (result!=STATE_OK) 1185 if (result!=STATE_OK)
1186 return result; 1186 return result;
1187 1187
1188 if (!strcmp(recv_buffer,"-1\n")) { 1188 if (!strcmp(recv_buffer,"-1\n")) {
1189 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name); 1189 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name);
1190 result=STATE_CRITICAL; 1190 result=STATE_CRITICAL;
1191 } else { 1191 } else {
1192 nss4_value=strtoul(recv_buffer,NULL,10); 1192 nss4_value=strtoul(recv_buffer,NULL,10);
@@ -1194,7 +1194,7 @@ main(int argc, char **argv) {
1194 result=STATE_CRITICAL; 1194 result=STATE_CRITICAL;
1195 else if (check_warning_value==TRUE && nss4_value >= warning_value) 1195 else if (check_warning_value==TRUE && nss4_value >= warning_value)
1196 result=STATE_WARNING; 1196 result=STATE_WARNING;
1197 asprintf (&output_message, 1197 xasprintf (&output_message,
1198 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1198 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1199 nss4_name, 1199 nss4_name,
1200 nss4_value, 1200 nss4_value,
@@ -1206,13 +1206,13 @@ main(int argc, char **argv) {
1206 1206
1207 } else if (vars_to_check==NSS5) { 1207 } else if (vars_to_check==NSS5) {
1208 1208
1209 asprintf (&send_buffer,"NSS5:%s\r\n",nss5_name); 1209 xasprintf (&send_buffer,"NSS5:%s\r\n",nss5_name);
1210 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1210 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1211 if (result!=STATE_OK) 1211 if (result!=STATE_OK)
1212 return result; 1212 return result;
1213 1213
1214 if (!strcmp(recv_buffer,"-1\n")) { 1214 if (!strcmp(recv_buffer,"-1\n")) {
1215 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name); 1215 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name);
1216 result=STATE_CRITICAL; 1216 result=STATE_CRITICAL;
1217 } else { 1217 } else {
1218 nss5_value=strtoul(recv_buffer,NULL,10); 1218 nss5_value=strtoul(recv_buffer,NULL,10);
@@ -1220,7 +1220,7 @@ main(int argc, char **argv) {
1220 result=STATE_CRITICAL; 1220 result=STATE_CRITICAL;
1221 else if (check_warning_value==TRUE && nss5_value >= warning_value) 1221 else if (check_warning_value==TRUE && nss5_value >= warning_value)
1222 result=STATE_WARNING; 1222 result=STATE_WARNING;
1223 asprintf (&output_message, 1223 xasprintf (&output_message,
1224 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1224 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1225 nss5_name, 1225 nss5_name,
1226 nss5_value, 1226 nss5_value,
@@ -1232,13 +1232,13 @@ main(int argc, char **argv) {
1232 1232
1233 } else if (vars_to_check==NSS6) { 1233 } else if (vars_to_check==NSS6) {
1234 1234
1235 asprintf (&send_buffer,"NSS6:%s\r\n",nss6_name); 1235 xasprintf (&send_buffer,"NSS6:%s\r\n",nss6_name);
1236 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1236 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1237 if (result!=STATE_OK) 1237 if (result!=STATE_OK)
1238 return result; 1238 return result;
1239 1239
1240 if (!strcmp(recv_buffer,"-1\n")) { 1240 if (!strcmp(recv_buffer,"-1\n")) {
1241 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name); 1241 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name);
1242 result=STATE_CRITICAL; 1242 result=STATE_CRITICAL;
1243 } else { 1243 } else {
1244 nss6_value=strtoul(recv_buffer,NULL,10); 1244 nss6_value=strtoul(recv_buffer,NULL,10);
@@ -1246,7 +1246,7 @@ main(int argc, char **argv) {
1246 result=STATE_CRITICAL; 1246 result=STATE_CRITICAL;
1247 else if (check_warning_value==TRUE && nss6_value >= warning_value) 1247 else if (check_warning_value==TRUE && nss6_value >= warning_value)
1248 result=STATE_WARNING; 1248 result=STATE_WARNING;
1249 asprintf (&output_message, 1249 xasprintf (&output_message,
1250 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1250 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1251 nss6_name, 1251 nss6_name,
1252 nss6_value, 1252 nss6_value,
@@ -1258,13 +1258,13 @@ main(int argc, char **argv) {
1258 1258
1259 } else if (vars_to_check==NSS7) { 1259 } else if (vars_to_check==NSS7) {
1260 1260
1261 asprintf (&send_buffer,"NSS7:%s\r\n",nss7_name); 1261 xasprintf (&send_buffer,"NSS7:%s\r\n",nss7_name);
1262 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1262 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1263 if (result!=STATE_OK) 1263 if (result!=STATE_OK)
1264 return result; 1264 return result;
1265 1265
1266 if (!strcmp(recv_buffer,"-1\n")) { 1266 if (!strcmp(recv_buffer,"-1\n")) {
1267 asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name); 1267 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name);
1268 result=STATE_CRITICAL; 1268 result=STATE_CRITICAL;
1269 } else { 1269 } else {
1270 nss7_value=strtoul(recv_buffer,NULL,10); 1270 nss7_value=strtoul(recv_buffer,NULL,10);
@@ -1272,7 +1272,7 @@ main(int argc, char **argv) {
1272 result=STATE_CRITICAL; 1272 result=STATE_CRITICAL;
1273 else if (check_warning_value==TRUE && nss7_value >= warning_value) 1273 else if (check_warning_value==TRUE && nss7_value >= warning_value)
1274 result=STATE_WARNING; 1274 result=STATE_WARNING;
1275 asprintf (&output_message, 1275 xasprintf (&output_message,
1276 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1276 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1277 nss7_name, 1277 nss7_name,
1278 nss7_value, 1278 nss7_value,
@@ -1591,7 +1591,7 @@ int process_arguments(int argc, char **argv) {
1591void print_help(void) 1591void print_help(void)
1592{ 1592{
1593 char *myport; 1593 char *myport;
1594 asprintf (&myport, "%d", PORT); 1594 xasprintf (&myport, "%d", PORT);
1595 1595
1596 print_revision (progname, NP_VERSION); 1596 print_revision (progname, NP_VERSION);
1597 1597
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c
index 16ada20d..95977e91 100644
--- a/plugins/check_overcr.c
+++ b/plugins/check_overcr.c
@@ -409,7 +409,7 @@ void
409print_help (void) 409print_help (void)
410{ 410{
411 char *myport; 411 char *myport;
412 asprintf (&myport, "%d", PORT); 412 xasprintf (&myport, "%d", PORT);
413 413
414 print_revision (progname, NP_VERSION); 414 print_revision (progname, NP_VERSION);
415 415
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 19c3117d..69edae75 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -417,7 +417,7 @@ print_help (void)
417{ 417{
418 char *myport; 418 char *myport;
419 419
420 asprintf (&myport, "%d", DEFAULT_PORT); 420 xasprintf (&myport, "%d", DEFAULT_PORT);
421 421
422 print_revision (progname, NP_VERSION); 422 print_revision (progname, NP_VERSION);
423 423
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 473f9f24..eef2195b 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -121,12 +121,12 @@ main (int argc, char **argv)
121 /* does the host address of number of packets argument come first? */ 121 /* does the host address of number of packets argument come first? */
122#ifdef PING_PACKETS_FIRST 122#ifdef PING_PACKETS_FIRST
123# ifdef PING_HAS_TIMEOUT 123# ifdef PING_HAS_TIMEOUT
124 asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]); 124 xasprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
125# else 125# else
126 asprintf (&cmd, rawcmd, max_packets, addresses[i]); 126 xasprintf (&cmd, rawcmd, max_packets, addresses[i]);
127# endif 127# endif
128#else 128#else
129 asprintf (&cmd, rawcmd, addresses[i], max_packets); 129 xasprintf (&cmd, rawcmd, addresses[i], max_packets);
130#endif 130#endif
131 131
132 if (verbose >= 2) 132 if (verbose >= 2)
@@ -491,7 +491,7 @@ run_ping (const char *cmd, const char *addr)
491 if (warn_text == NULL) { 491 if (warn_text == NULL) {
492 warn_text = strdup(_("System call sent warnings to stderr ")); 492 warn_text = strdup(_("System call sent warnings to stderr "));
493 } else { 493 } else {
494 asprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr ")); 494 xasprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
495 } 495 }
496 } 496 }
497 } 497 }
@@ -540,7 +540,7 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
540 if (warn_text == NULL) 540 if (warn_text == NULL)
541 warn_text = strdup (_(WARN_DUPLICATES)); 541 warn_text = strdup (_(WARN_DUPLICATES));
542 else if (! strstr (warn_text, _(WARN_DUPLICATES)) && 542 else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
543 asprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1) 543 xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
544 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n")); 544 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
545 return (STATE_WARNING); 545 return (STATE_WARNING);
546 } 546 }
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index d875a618..2f2dcc58 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -137,7 +137,7 @@ main (int argc, char **argv)
137 input_buffer = malloc (MAX_INPUT_BUFFER); 137 input_buffer = malloc (MAX_INPUT_BUFFER);
138 procprog = malloc (MAX_INPUT_BUFFER); 138 procprog = malloc (MAX_INPUT_BUFFER);
139 139
140 asprintf (&metric_name, "PROCS"); 140 xasprintf (&metric_name, "PROCS");
141 metric = METRIC_PROCS; 141 metric = METRIC_PROCS;
142 142
143 /* Parse extra opts if any */ 143 /* Parse extra opts if any */
@@ -176,7 +176,7 @@ main (int argc, char **argv)
176 printf ("%s", input_line); 176 printf ("%s", input_line);
177 177
178 strcpy (procprog, ""); 178 strcpy (procprog, "");
179 asprintf (&procargs, "%s", ""); 179 xasprintf (&procargs, "%s", "");
180 180
181 cols = sscanf (input_line, PS_FORMAT, PS_VARLIST); 181 cols = sscanf (input_line, PS_FORMAT, PS_VARLIST);
182 182
@@ -186,7 +186,7 @@ main (int argc, char **argv)
186 } 186 }
187 if ( cols >= expected_cols ) { 187 if ( cols >= expected_cols ) {
188 resultsum = 0; 188 resultsum = 0;
189 asprintf (&procargs, "%s", input_line + pos); 189 xasprintf (&procargs, "%s", input_line + pos);
190 strip (procargs); 190 strip (procargs);
191 191
192 /* Some ps return full pathname for command. This removes path */ 192 /* Some ps return full pathname for command. This removes path */
@@ -250,12 +250,12 @@ main (int argc, char **argv)
250 if (metric != METRIC_PROCS) { 250 if (metric != METRIC_PROCS) {
251 if (i == STATE_WARNING) { 251 if (i == STATE_WARNING) {
252 warn++; 252 warn++;
253 asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog); 253 xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
254 result = max_state (result, i); 254 result = max_state (result, i);
255 } 255 }
256 if (i == STATE_CRITICAL) { 256 if (i == STATE_CRITICAL) {
257 crit++; 257 crit++;
258 asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog); 258 xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
259 result = max_state (result, i); 259 result = max_state (result, i);
260 } 260 }
261 } 261 }
@@ -393,7 +393,7 @@ process_arguments (int argc, char **argv)
393 break; 393 break;
394 case 'p': /* process id */ 394 case 'p': /* process id */
395 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) { 395 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
396 asprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid); 396 xasprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid);
397 options |= PPID; 397 options |= PPID;
398 break; 398 break;
399 } 399 }
@@ -403,7 +403,7 @@ process_arguments (int argc, char **argv)
403 break; 403 break;
404 else 404 else
405 statopts = optarg; 405 statopts = optarg;
406 asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); 406 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
407 options |= STAT; 407 options |= STAT;
408 break; 408 break;
409 case 'u': /* user or user id */ 409 case 'u': /* user or user id */
@@ -423,7 +423,7 @@ process_arguments (int argc, char **argv)
423 uid = pw->pw_uid; 423 uid = pw->pw_uid;
424 } 424 }
425 user = pw->pw_name; 425 user = pw->pw_name;
426 asprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""), 426 xasprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""),
427 uid, user); 427 uid, user);
428 options |= USER; 428 options |= USER;
429 break; 429 break;
@@ -433,7 +433,7 @@ process_arguments (int argc, char **argv)
433 break; 433 break;
434 else 434 else
435 prog = optarg; 435 prog = optarg;
436 asprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""), 436 xasprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
437 prog); 437 prog);
438 options |= PROG; 438 options |= PROG;
439 break; 439 break;
@@ -443,7 +443,7 @@ process_arguments (int argc, char **argv)
443 break; 443 break;
444 else 444 else
445 args = optarg; 445 args = optarg;
446 asprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args); 446 xasprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args);
447 options |= ARGS; 447 options |= ARGS;
448 break; 448 break;
449 case CHAR_MAX+1: 449 case CHAR_MAX+1:
@@ -459,19 +459,19 @@ process_arguments (int argc, char **argv)
459 temp_string[i]=','; 459 temp_string[i]=',';
460 i++; 460 i++;
461 } 461 }
462 asprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string); 462 xasprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string);
463 options |= EREG_ARGS; 463 options |= EREG_ARGS;
464 break; 464 break;
465 case 'r': /* RSS */ 465 case 'r': /* RSS */
466 if (sscanf (optarg, "%d%[^0-9]", &rss, tmp) == 1) { 466 if (sscanf (optarg, "%d%[^0-9]", &rss, tmp) == 1) {
467 asprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss); 467 xasprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss);
468 options |= RSS; 468 options |= RSS;
469 break; 469 break;
470 } 470 }
471 usage4 (_("RSS must be an integer!")); 471 usage4 (_("RSS must be an integer!"));
472 case 'z': /* VSZ */ 472 case 'z': /* VSZ */
473 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) { 473 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
474 asprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz); 474 xasprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz);
475 options |= VSZ; 475 options |= VSZ;
476 break; 476 break;
477 } 477 }
@@ -479,13 +479,13 @@ process_arguments (int argc, char **argv)
479 case 'P': /* PCPU */ 479 case 'P': /* PCPU */
480 /* TODO: -P 1.5.5 is accepted */ 480 /* TODO: -P 1.5.5 is accepted */
481 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) { 481 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
482 asprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu); 482 xasprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu);
483 options |= PCPU; 483 options |= PCPU;
484 break; 484 break;
485 } 485 }
486 usage4 (_("PCPU must be a float!")); 486 usage4 (_("PCPU must be a float!"));
487 case 'm': 487 case 'm':
488 asprintf (&metric_name, "%s", optarg); 488 xasprintf (&metric_name, "%s", optarg);
489 if ( strcmp(optarg, "PROCS") == 0) { 489 if ( strcmp(optarg, "PROCS") == 0) {
490 metric = METRIC_PROCS; 490 metric = METRIC_PROCS;
491 break; 491 break;
@@ -523,8 +523,8 @@ process_arguments (int argc, char **argv)
523 if (cmax == -1 && argv[c]) 523 if (cmax == -1 && argv[c])
524 cmax = atoi (argv[c++]); 524 cmax = atoi (argv[c++]);
525 if (statopts == NULL && argv[c]) { 525 if (statopts == NULL && argv[c]) {
526 asprintf (&statopts, "%s", argv[c++]); 526 xasprintf (&statopts, "%s", argv[c++]);
527 asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); 527 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
528 options |= STAT; 528 options |= STAT;
529 } 529 }
530 530
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index c2c93eeb..e54105b0 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -328,7 +328,7 @@ void
328print_help (void) 328print_help (void)
329{ 329{
330 char *myport; 330 char *myport;
331 asprintf (&myport, "%d", PW_AUTH_UDP_PORT); 331 xasprintf (&myport, "%d", PW_AUTH_UDP_PORT);
332 332
333 print_revision (progname, NP_VERSION); 333 print_revision (progname, NP_VERSION);
334 334
diff --git a/plugins/check_real.c b/plugins/check_real.c
index d67e1904..18240f30 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -403,7 +403,7 @@ void
403print_help (void) 403print_help (void)
404{ 404{
405 char *myport; 405 char *myport;
406 asprintf (&myport, "%d", PORT); 406 xasprintf (&myport, "%d", PORT);
407 407
408 print_revision (progname, NP_VERSION); 408 print_revision (progname, NP_VERSION);
409 409
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 77ac5ced..6b3f9dd4 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -156,15 +156,15 @@ main (int argc, char **argv)
156 } 156 }
157 } 157 }
158 if(use_ehlo) 158 if(use_ehlo)
159 asprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 159 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
160 else 160 else
161 asprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 161 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
162 162
163 if (verbose) 163 if (verbose)
164 printf("HELOCMD: %s", helocmd); 164 printf("HELOCMD: %s", helocmd);
165 165
166 /* initialize the MAIL command with optional FROM command */ 166 /* initialize the MAIL command with optional FROM command */
167 asprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n"); 167 xasprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
168 168
169 if (verbose && smtp_use_dummycmd) 169 if (verbose && smtp_use_dummycmd)
170 printf ("FROM CMD: %s", cmd_str); 170 printf ("FROM CMD: %s", cmd_str);
@@ -299,7 +299,7 @@ main (int argc, char **argv)
299 } 299 }
300 300
301 while (n < ncommands) { 301 while (n < ncommands) {
302 asprintf (&cmd_str, "%s%s", commands[n], "\r\n"); 302 xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
303 my_send(cmd_str, strlen(cmd_str)); 303 my_send(cmd_str, strlen(cmd_str));
304 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose) 304 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
305 printf("%s", buffer); 305 printf("%s", buffer);
@@ -336,12 +336,12 @@ main (int argc, char **argv)
336 do { 336 do {
337 if (authuser == NULL) { 337 if (authuser == NULL) {
338 result = STATE_CRITICAL; 338 result = STATE_CRITICAL;
339 asprintf(&error_msg, _("no authuser specified, ")); 339 xasprintf(&error_msg, _("no authuser specified, "));
340 break; 340 break;
341 } 341 }
342 if (authpass == NULL) { 342 if (authpass == NULL) {
343 result = STATE_CRITICAL; 343 result = STATE_CRITICAL;
344 asprintf(&error_msg, _("no authpass specified, ")); 344 xasprintf(&error_msg, _("no authpass specified, "));
345 break; 345 break;
346 } 346 }
347 347
@@ -351,7 +351,7 @@ main (int argc, char **argv)
351 printf (_("sent %s\n"), "AUTH LOGIN"); 351 printf (_("sent %s\n"), "AUTH LOGIN");
352 352
353 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 353 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
354 asprintf(&error_msg, _("recv() failed after AUTH LOGIN, ")); 354 xasprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
355 result = STATE_WARNING; 355 result = STATE_WARNING;
356 break; 356 break;
357 } 357 }
@@ -360,7 +360,7 @@ main (int argc, char **argv)
360 360
361 if (strncmp (buffer, "334", 3) != 0) { 361 if (strncmp (buffer, "334", 3) != 0) {
362 result = STATE_CRITICAL; 362 result = STATE_CRITICAL;
363 asprintf(&error_msg, _("invalid response received after AUTH LOGIN, ")); 363 xasprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
364 break; 364 break;
365 } 365 }
366 366
@@ -374,7 +374,7 @@ main (int argc, char **argv)
374 374
375 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 375 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
376 result = STATE_CRITICAL; 376 result = STATE_CRITICAL;
377 asprintf(&error_msg, _("recv() failed after sending authuser, ")); 377 xasprintf(&error_msg, _("recv() failed after sending authuser, "));
378 break; 378 break;
379 } 379 }
380 if (verbose) { 380 if (verbose) {
@@ -382,7 +382,7 @@ main (int argc, char **argv)
382 } 382 }
383 if (strncmp (buffer, "334", 3) != 0) { 383 if (strncmp (buffer, "334", 3) != 0) {
384 result = STATE_CRITICAL; 384 result = STATE_CRITICAL;
385 asprintf(&error_msg, _("invalid response received after authuser, ")); 385 xasprintf(&error_msg, _("invalid response received after authuser, "));
386 break; 386 break;
387 } 387 }
388 /* encode authpass with base64 */ 388 /* encode authpass with base64 */
@@ -395,7 +395,7 @@ main (int argc, char **argv)
395 } 395 }
396 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 396 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
397 result = STATE_CRITICAL; 397 result = STATE_CRITICAL;
398 asprintf(&error_msg, _("recv() failed after sending authpass, ")); 398 xasprintf(&error_msg, _("recv() failed after sending authpass, "));
399 break; 399 break;
400 } 400 }
401 if (verbose) { 401 if (verbose) {
@@ -403,14 +403,14 @@ main (int argc, char **argv)
403 } 403 }
404 if (strncmp (buffer, "235", 3) != 0) { 404 if (strncmp (buffer, "235", 3) != 0) {
405 result = STATE_CRITICAL; 405 result = STATE_CRITICAL;
406 asprintf(&error_msg, _("invalid response received after authpass, ")); 406 xasprintf(&error_msg, _("invalid response received after authpass, "));
407 break; 407 break;
408 } 408 }
409 break; 409 break;
410 } while (0); 410 } while (0);
411 } else { 411 } else {
412 result = STATE_CRITICAL; 412 result = STATE_CRITICAL;
413 asprintf(&error_msg, _("only authtype LOGIN is supported, ")); 413 xasprintf(&error_msg, _("only authtype LOGIN is supported, "));
414 } 414 }
415 } 415 }
416 416
@@ -654,7 +654,7 @@ process_arguments (int argc, char **argv)
654 usage2 (_("Invalid hostname/address"), argv[c]); 654 usage2 (_("Invalid hostname/address"), argv[c]);
655 } 655 }
656 else { 656 else {
657 asprintf (&server_address, "127.0.0.1"); 657 xasprintf (&server_address, "127.0.0.1");
658 } 658 }
659 } 659 }
660 660
@@ -787,7 +787,7 @@ void
787print_help (void) 787print_help (void)
788{ 788{
789 char *myport; 789 char *myport;
790 asprintf (&myport, "%d", SMTP_PORT); 790 xasprintf (&myport, "%d", SMTP_PORT);
791 791
792 print_revision (progname, NP_VERSION); 792 print_revision (progname, NP_VERSION);
793 793
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index a5a88d25..2d9861bc 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -255,9 +255,9 @@ main (int argc, char **argv)
255 command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *)); 255 command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *));
256 command_line[0] = snmpcmd; 256 command_line[0] = snmpcmd;
257 command_line[1] = strdup ("-t"); 257 command_line[1] = strdup ("-t");
258 asprintf (&command_line[2], "%d", timeout_interval); 258 xasprintf (&command_line[2], "%d", timeout_interval);
259 command_line[3] = strdup ("-r"); 259 command_line[3] = strdup ("-r");
260 asprintf (&command_line[4], "%d", retries); 260 xasprintf (&command_line[4], "%d", retries);
261 command_line[5] = strdup ("-m"); 261 command_line[5] = strdup ("-m");
262 command_line[6] = strdup (miblist); 262 command_line[6] = strdup (miblist);
263 command_line[7] = "-v"; 263 command_line[7] = "-v";
@@ -267,16 +267,16 @@ main (int argc, char **argv)
267 command_line[9 + i] = authpriv[i]; 267 command_line[9 + i] = authpriv[i];
268 } 268 }
269 269
270 asprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port); 270 xasprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port);
271 271
272 /* This is just for display purposes, so it can remain a string */ 272 /* This is just for display purposes, so it can remain a string */
273 asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s", 273 xasprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s",
274 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", 274 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]",
275 server_address, port); 275 server_address, port);
276 276
277 for (i = 0; i < numoids; i++) { 277 for (i = 0; i < numoids; i++) {
278 command_line[9 + numauthpriv + 1 + i] = oids[i]; 278 command_line[9 + numauthpriv + 1 + i] = oids[i];
279 asprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); 279 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
280 } 280 }
281 281
282 command_line[9 + numauthpriv + 1 + numoids] = NULL; 282 command_line[9 + numauthpriv + 1 + numoids] = NULL;
@@ -371,14 +371,14 @@ main (int argc, char **argv)
371 if (dq_count) { /* unfinished line */ 371 if (dq_count) { /* unfinished line */
372 /* copy show verbatim first */ 372 /* copy show verbatim first */
373 if (!mult_resp) mult_resp = strdup(""); 373 if (!mult_resp) mult_resp = strdup("");
374 asprintf (&mult_resp, "%s%s:\n%s\n", mult_resp, oids[i], show); 374 xasprintf (&mult_resp, "%s%s:\n%s\n", mult_resp, oids[i], show);
375 /* then strip out unmatched double-quote from single-line output */ 375 /* then strip out unmatched double-quote from single-line output */
376 if (show[0] == '"') show++; 376 if (show[0] == '"') show++;
377 377
378 /* Keep reading until we match end of double-quoted string */ 378 /* Keep reading until we match end of double-quoted string */
379 for (line++; line < chld_out.lines; line++) { 379 for (line++; line < chld_out.lines; line++) {
380 ptr = chld_out.line[line]; 380 ptr = chld_out.line[line];
381 asprintf (&mult_resp, "%s%s\n", mult_resp, ptr); 381 xasprintf (&mult_resp, "%s%s\n", mult_resp, ptr);
382 382
383 COUNT_SEQ(ptr, bk_count, dq_count) 383 COUNT_SEQ(ptr, bk_count, dq_count)
384 while (dq_count && ptr[0] != '\n' && ptr[0] != '\0') { 384 while (dq_count && ptr[0] != '\n' && ptr[0] != '\0') {
@@ -424,11 +424,11 @@ main (int argc, char **argv)
424 /* Convert to per second, then use multiplier */ 424 /* Convert to per second, then use multiplier */
425 temp_double = temp_double/duration*rate_multiplier; 425 temp_double = temp_double/duration*rate_multiplier;
426 iresult = get_status(temp_double, thlds[i]); 426 iresult = get_status(temp_double, thlds[i]);
427 asprintf (&show, conv, temp_double); 427 xasprintf (&show, conv, temp_double);
428 } 428 }
429 } else { 429 } else {
430 iresult = get_status(response_value[i], thlds[i]); 430 iresult = get_status(response_value[i], thlds[i]);
431 asprintf (&show, conv, response_value[i]); 431 xasprintf (&show, conv, response_value[i]);
432 } 432 }
433 } 433 }
434 434
@@ -472,16 +472,16 @@ main (int argc, char **argv)
472 472
473 /* Prepend a label for this OID if there is one */ 473 /* Prepend a label for this OID if there is one */
474 if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) 474 if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL)
475 asprintf (&outbuff, "%s%s%s %s%s%s", outbuff, 475 xasprintf (&outbuff, "%s%s%s %s%s%s", outbuff,
476 (i == 0) ? " " : output_delim, 476 (i == 0) ? " " : output_delim,
477 labels[i], mark (iresult), show, mark (iresult)); 477 labels[i], mark (iresult), show, mark (iresult));
478 else 478 else
479 asprintf (&outbuff, "%s%s%s%s%s", outbuff, (i == 0) ? " " : output_delim, 479 xasprintf (&outbuff, "%s%s%s%s%s", outbuff, (i == 0) ? " " : output_delim,
480 mark (iresult), show, mark (iresult)); 480 mark (iresult), show, mark (iresult));
481 481
482 /* Append a unit string for this OID if there is one */ 482 /* Append a unit string for this OID if there is one */
483 if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) 483 if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
484 asprintf (&outbuff, "%s %s", outbuff, unitv[i]); 484 xasprintf (&outbuff, "%s %s", outbuff, unitv[i]);
485 485
486 /* Write perfdata with whatever can be parsed by strtod, if possible */ 486 /* Write perfdata with whatever can be parsed by strtod, if possible */
487 ptr = NULL; 487 ptr = NULL;
@@ -523,7 +523,7 @@ main (int argc, char **argv)
523 523
524 current_length=0; 524 current_length=0;
525 for(i=0; i<total_oids; i++) { 525 for(i=0; i<total_oids; i++) {
526 asprintf(&temp_string,"%.0f",response_value[i]); 526 xasprintf(&temp_string,"%.0f",response_value[i]);
527 if(temp_string==NULL) 527 if(temp_string==NULL)
528 die(STATE_UNKNOWN,_("Cannot asprintf()")); 528 die(STATE_UNKNOWN,_("Cannot asprintf()"));
529 response_length = strlen(temp_string); 529 response_length = strlen(temp_string);
@@ -869,7 +869,7 @@ validate_arguments ()
869 die(STATE_UNKNOWN, _("No OIDs specified\n")); 869 die(STATE_UNKNOWN, _("No OIDs specified\n"));
870 870
871 if (proto == NULL) 871 if (proto == NULL)
872 asprintf(&proto, DEFAULT_PROTOCOL); 872 xasprintf(&proto, DEFAULT_PROTOCOL);
873 873
874 if ((strcmp(proto,"1") == 0) || (strcmp(proto, "2c")==0)) { /* snmpv1 or snmpv2c */ 874 if ((strcmp(proto,"1") == 0) || (strcmp(proto, "2c")==0)) { /* snmpv1 or snmpv2c */
875 numauthpriv = 2; 875 numauthpriv = 2;
@@ -879,7 +879,7 @@ validate_arguments ()
879 } 879 }
880 else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ 880 else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
881 if (seclevel == NULL) 881 if (seclevel == NULL)
882 asprintf(&seclevel, "noAuthNoPriv"); 882 xasprintf(&seclevel, "noAuthNoPriv");
883 883
884 if (strcmp(seclevel, "noAuthNoPriv") == 0) { 884 if (strcmp(seclevel, "noAuthNoPriv") == 0) {
885 numauthpriv = 2; 885 numauthpriv = 2;
@@ -892,7 +892,7 @@ validate_arguments ()
892 } 892 }
893 893
894 if (authproto == NULL ) 894 if (authproto == NULL )
895 asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); 895 xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
896 896
897 if (secname == NULL) 897 if (secname == NULL)
898 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname"); 898 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
@@ -913,7 +913,7 @@ validate_arguments ()
913 authpriv[7] = strdup (authpasswd); 913 authpriv[7] = strdup (authpasswd);
914 } else if ( strcmp(seclevel, "authPriv") == 0 ) { 914 } else if ( strcmp(seclevel, "authPriv") == 0 ) {
915 if (privproto == NULL ) 915 if (privproto == NULL )
916 asprintf(&privproto, DEFAULT_PRIV_PROTOCOL); 916 xasprintf(&privproto, DEFAULT_PRIV_PROTOCOL);
917 917
918 if (privpasswd == NULL) 918 if (privpasswd == NULL)
919 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "privpasswd"); 919 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "privpasswd");
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 3bbf44dc..4d633949 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -241,7 +241,7 @@ ssh_connect (char *haddr, int hport, char *remote_version)
241 ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. "); 241 ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");
242 ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0; 242 ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
243 243
244 asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no); 244 xasprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
245 send (sd, buffer, strlen (buffer), MSG_DONTWAIT); 245 send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
246 if (verbose) 246 if (verbose)
247 printf ("%s\n", buffer); 247 printf ("%s\n", buffer);
@@ -271,7 +271,7 @@ void
271print_help (void) 271print_help (void)
272{ 272{
273 char *myport; 273 char *myport;
274 asprintf (&myport, "%d", SSH_DFL_PORT); 274 xasprintf (&myport, "%d", SSH_DFL_PORT);
275 275
276 print_revision (progname, NP_VERSION); 276 print_revision (progname, NP_VERSION);
277 277
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index ce1f6022..1b2a8dd5 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -129,7 +129,7 @@ main (int argc, char **argv)
129 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 129 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
130 result = max_state (result, check_swap (percent, dskfree_mb)); 130 result = max_state (result, check_swap (percent, dskfree_mb));
131 if (verbose) 131 if (verbose)
132 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 132 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
133 } 133 }
134 } 134 }
135 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { 135 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) {
@@ -152,15 +152,15 @@ main (int argc, char **argv)
152 free_swap_mb = dskfree_mb; 152 free_swap_mb = dskfree_mb;
153#else 153#else
154# ifdef HAVE_SWAP 154# ifdef HAVE_SWAP
155 asprintf(&swap_command, "%s", SWAP_COMMAND); 155 xasprintf(&swap_command, "%s", SWAP_COMMAND);
156 asprintf(&swap_format, "%s", SWAP_FORMAT); 156 xasprintf(&swap_format, "%s", SWAP_FORMAT);
157 157
158/* These override the command used if a summary (and thus ! allswaps) is required */ 158/* These override the command used if a summary (and thus ! allswaps) is required */
159/* The summary flag returns more accurate information about swap usage on these OSes */ 159/* The summary flag returns more accurate information about swap usage on these OSes */
160# ifdef _AIX 160# ifdef _AIX
161 if (!allswaps) { 161 if (!allswaps) {
162 asprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); 162 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
163 asprintf(&swap_format, "%s", "%f%*s %f"); 163 xasprintf(&swap_format, "%s", "%f%*s %f");
164 conv_factor = 1; 164 conv_factor = 1;
165 } 165 }
166# endif 166# endif
@@ -228,7 +228,7 @@ main (int argc, char **argv)
228 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 228 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
229 result = max_state (result, check_swap (percent, dskfree_mb)); 229 result = max_state (result, check_swap (percent, dskfree_mb));
230 if (verbose) 230 if (verbose)
231 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 231 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
232 } 232 }
233 } 233 }
234# ifdef _AIX 234# ifdef _AIX
@@ -290,7 +290,7 @@ main (int argc, char **argv)
290 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 290 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
291 result = max_state (result, check_swap (percent, dskfree_mb)); 291 result = max_state (result, check_swap (percent, dskfree_mb));
292 if (verbose) { 292 if (verbose) {
293 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 293 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
294 } 294 }
295 } 295 }
296 296
@@ -329,7 +329,7 @@ main (int argc, char **argv)
329 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 329 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
330 result = max_state (result, check_swap (percent, dskfree_mb)); 330 result = max_state (result, check_swap (percent, dskfree_mb));
331 if (verbose) { 331 if (verbose) {
332 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 332 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
333 } 333 }
334 } 334 }
335 335
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 1bbb05a3..f464b15f 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -502,7 +502,7 @@ process_arguments (int argc, char **argv)
502 if (escape) 502 if (escape)
503 server_send = np_escaped_string(optarg); 503 server_send = np_escaped_string(optarg);
504 else 504 else
505 asprintf(&server_send, "%s", optarg); 505 xasprintf(&server_send, "%s", optarg);
506 break; 506 break;
507 case 'e': /* expect string (may be repeated) */ 507 case 'e': /* expect string (may be repeated) */
508 flags &= ~FLAG_EXACT_MATCH; 508 flags &= ~FLAG_EXACT_MATCH;
@@ -522,7 +522,7 @@ process_arguments (int argc, char **argv)
522 if (escape) 522 if (escape)
523 server_quit = np_escaped_string(optarg); 523 server_quit = np_escaped_string(optarg);
524 else 524 else
525 asprintf(&server_quit, "%s\r\n", optarg); 525 xasprintf(&server_quit, "%s\r\n", optarg);
526 break; 526 break;
527 case 'r': 527 case 'r':
528 if (!strncmp(optarg,"ok",2)) 528 if (!strncmp(optarg,"ok",2))
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 3dcc662c..7ee014e9 100644
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
@@ -329,7 +329,7 @@ void
329print_help (void) 329print_help (void)
330{ 330{
331 char *myport; 331 char *myport;
332 asprintf (&myport, "%d", TIME_PORT); 332 xasprintf (&myport, "%d", TIME_PORT);
333 333
334 print_revision (progname, NP_VERSION); 334 print_revision (progname, NP_VERSION);
335 335
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 30c9357a..59dcc264 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -136,56 +136,56 @@ main (int argc, char **argv)
136 result = STATE_OK; 136 result = STATE_OK;
137 137
138 if (status & UPSSTATUS_OFF) { 138 if (status & UPSSTATUS_OFF) {
139 asprintf (&ups_status, "Off"); 139 xasprintf (&ups_status, "Off");
140 result = STATE_CRITICAL; 140 result = STATE_CRITICAL;
141 } 141 }
142 else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) == 142 else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
143 (UPSSTATUS_OB | UPSSTATUS_LB)) { 143 (UPSSTATUS_OB | UPSSTATUS_LB)) {
144 asprintf (&ups_status, _("On Battery, Low Battery")); 144 xasprintf (&ups_status, _("On Battery, Low Battery"));
145 result = STATE_CRITICAL; 145 result = STATE_CRITICAL;
146 } 146 }
147 else { 147 else {
148 if (status & UPSSTATUS_OL) { 148 if (status & UPSSTATUS_OL) {
149 asprintf (&ups_status, "%s%s", ups_status, _("Online")); 149 xasprintf (&ups_status, "%s%s", ups_status, _("Online"));
150 } 150 }
151 if (status & UPSSTATUS_OB) { 151 if (status & UPSSTATUS_OB) {
152 asprintf (&ups_status, "%s%s", ups_status, _("On Battery")); 152 xasprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
153 result = STATE_WARNING; 153 result = STATE_WARNING;
154 } 154 }
155 if (status & UPSSTATUS_LB) { 155 if (status & UPSSTATUS_LB) {
156 asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery")); 156 xasprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
157 result = STATE_WARNING; 157 result = STATE_WARNING;
158 } 158 }
159 if (status & UPSSTATUS_CAL) { 159 if (status & UPSSTATUS_CAL) {
160 asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating")); 160 xasprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
161 } 161 }
162 if (status & UPSSTATUS_RB) { 162 if (status & UPSSTATUS_RB) {
163 asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery")); 163 xasprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
164 result = STATE_WARNING; 164 result = STATE_WARNING;
165 } 165 }
166 if (status & UPSSTATUS_BYPASS) { 166 if (status & UPSSTATUS_BYPASS) {
167 asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass")); 167 xasprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
168 } 168 }
169 if (status & UPSSTATUS_OVER) { 169 if (status & UPSSTATUS_OVER) {
170 asprintf (&ups_status, "%s%s", ups_status, _(", Overload")); 170 xasprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
171 } 171 }
172 if (status & UPSSTATUS_TRIM) { 172 if (status & UPSSTATUS_TRIM) {
173 asprintf (&ups_status, "%s%s", ups_status, _(", Trimming")); 173 xasprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
174 } 174 }
175 if (status & UPSSTATUS_BOOST) { 175 if (status & UPSSTATUS_BOOST) {
176 asprintf (&ups_status, "%s%s", ups_status, _(", Boosting")); 176 xasprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
177 } 177 }
178 if (status & UPSSTATUS_CHRG) { 178 if (status & UPSSTATUS_CHRG) {
179 asprintf (&ups_status, "%s%s", ups_status, _(", Charging")); 179 xasprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
180 } 180 }
181 if (status & UPSSTATUS_DISCHRG) { 181 if (status & UPSSTATUS_DISCHRG) {
182 asprintf (&ups_status, "%s%s", ups_status, _(", Discharging")); 182 xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
183 } 183 }
184 if (status & UPSSTATUS_UNKOWN) { 184 if (status & UPSSTATUS_UNKOWN) {
185 asprintf (&ups_status, "%s%s", ups_status, _(", Unknown")); 185 xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
186 } 186 }
187 } 187 }
188 asprintf (&message, "%sStatus=%s ", message, ups_status); 188 xasprintf (&message, "%sStatus=%s ", message, ups_status);
189 } 189 }
190 190
191 /* get the ups utility voltage if possible */ 191 /* get the ups utility voltage if possible */
@@ -197,7 +197,7 @@ main (int argc, char **argv)
197 supported_options |= UPS_UTILITY; 197 supported_options |= UPS_UTILITY;
198 198
199 ups_utility_voltage = atof (temp_buffer); 199 ups_utility_voltage = atof (temp_buffer);
200 asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); 200 xasprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
201 201
202 if (ups_utility_voltage > 120.0) 202 if (ups_utility_voltage > 120.0)
203 ups_utility_deviation = 120.0 - ups_utility_voltage; 203 ups_utility_deviation = 120.0 - ups_utility_voltage;
@@ -211,13 +211,13 @@ main (int argc, char **argv)
211 else if (check_warn==TRUE && ups_utility_deviation>=warning_value) { 211 else if (check_warn==TRUE && ups_utility_deviation>=warning_value) {
212 result = max_state (result, STATE_WARNING); 212 result = max_state (result, STATE_WARNING);
213 } 213 }
214 asprintf (&data, "%s", 214 xasprintf (&data, "%s",
215 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", 215 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
216 check_warn, (long)(1000*warning_value), 216 check_warn, (long)(1000*warning_value),
217 check_crit, (long)(1000*critical_value), 217 check_crit, (long)(1000*critical_value),
218 TRUE, 0, FALSE, 0)); 218 TRUE, 0, FALSE, 0));
219 } else { 219 } else {
220 asprintf (&data, "%s", 220 xasprintf (&data, "%s",
221 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", 221 perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
222 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 222 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
223 } 223 }
@@ -231,7 +231,7 @@ main (int argc, char **argv)
231 else { 231 else {
232 supported_options |= UPS_BATTPCT; 232 supported_options |= UPS_BATTPCT;
233 ups_battery_percent = atof (temp_buffer); 233 ups_battery_percent = atof (temp_buffer);
234 asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); 234 xasprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
235 235
236 if (check_variable == UPS_BATTPCT) { 236 if (check_variable == UPS_BATTPCT) {
237 if (check_crit==TRUE && ups_battery_percent <= critical_value) { 237 if (check_crit==TRUE && ups_battery_percent <= critical_value) {
@@ -240,13 +240,13 @@ main (int argc, char **argv)
240 else if (check_warn==TRUE && ups_battery_percent<=warning_value) { 240 else if (check_warn==TRUE && ups_battery_percent<=warning_value) {
241 result = max_state (result, STATE_WARNING); 241 result = max_state (result, STATE_WARNING);
242 } 242 }
243 asprintf (&data, "%s %s", data, 243 xasprintf (&data, "%s %s", data,
244 perfdata ("battery", (long)ups_battery_percent, "%", 244 perfdata ("battery", (long)ups_battery_percent, "%",
245 check_warn, (long)(1000*warning_value), 245 check_warn, (long)(1000*warning_value),
246 check_crit, (long)(1000*critical_value), 246 check_crit, (long)(1000*critical_value),
247 TRUE, 0, TRUE, 100)); 247 TRUE, 0, TRUE, 100));
248 } else { 248 } else {
249 asprintf (&data, "%s %s", data, 249 xasprintf (&data, "%s %s", data,
250 perfdata ("battery", (long)ups_battery_percent, "%", 250 perfdata ("battery", (long)ups_battery_percent, "%",
251 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); 251 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
252 } 252 }
@@ -260,7 +260,7 @@ main (int argc, char **argv)
260 else { 260 else {
261 supported_options |= UPS_LOADPCT; 261 supported_options |= UPS_LOADPCT;
262 ups_load_percent = atof (temp_buffer); 262 ups_load_percent = atof (temp_buffer);
263 asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); 263 xasprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
264 264
265 if (check_variable == UPS_LOADPCT) { 265 if (check_variable == UPS_LOADPCT) {
266 if (check_crit==TRUE && ups_load_percent>=critical_value) { 266 if (check_crit==TRUE && ups_load_percent>=critical_value) {
@@ -269,13 +269,13 @@ main (int argc, char **argv)
269 else if (check_warn==TRUE && ups_load_percent>=warning_value) { 269 else if (check_warn==TRUE && ups_load_percent>=warning_value) {
270 result = max_state (result, STATE_WARNING); 270 result = max_state (result, STATE_WARNING);
271 } 271 }
272 asprintf (&data, "%s %s", data, 272 xasprintf (&data, "%s %s", data,
273 perfdata ("load", (long)ups_load_percent, "%", 273 perfdata ("load", (long)ups_load_percent, "%",
274 check_warn, (long)(1000*warning_value), 274 check_warn, (long)(1000*warning_value),
275 check_crit, (long)(1000*critical_value), 275 check_crit, (long)(1000*critical_value),
276 TRUE, 0, TRUE, 100)); 276 TRUE, 0, TRUE, 100));
277 } else { 277 } else {
278 asprintf (&data, "%s %s", data, 278 xasprintf (&data, "%s %s", data,
279 perfdata ("load", (long)ups_load_percent, "%", 279 perfdata ("load", (long)ups_load_percent, "%",
280 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); 280 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
281 } 281 }
@@ -291,12 +291,12 @@ main (int argc, char **argv)
291 if (temp_output_c) { 291 if (temp_output_c) {
292 tunits="degC"; 292 tunits="degC";
293 ups_temperature = atof (temp_buffer); 293 ups_temperature = atof (temp_buffer);
294 asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature); 294 xasprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
295 } 295 }
296 else { 296 else {
297 tunits="degF"; 297 tunits="degF";
298 ups_temperature = (atof (temp_buffer) * 1.8) + 32; 298 ups_temperature = (atof (temp_buffer) * 1.8) + 32;
299 asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); 299 xasprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
300 } 300 }
301 301
302 if (check_variable == UPS_TEMP) { 302 if (check_variable == UPS_TEMP) {
@@ -306,13 +306,13 @@ main (int argc, char **argv)
306 else if (check_warn == TRUE && ups_temperature>=warning_value) { 306 else if (check_warn == TRUE && ups_temperature>=warning_value) {
307 result = max_state (result, STATE_WARNING); 307 result = max_state (result, STATE_WARNING);
308 } 308 }
309 asprintf (&data, "%s %s", data, 309 xasprintf (&data, "%s %s", data,
310 perfdata ("temp", (long)ups_temperature, tunits, 310 perfdata ("temp", (long)ups_temperature, tunits,
311 check_warn, (long)(1000*warning_value), 311 check_warn, (long)(1000*warning_value),
312 check_crit, (long)(1000*critical_value), 312 check_crit, (long)(1000*critical_value),
313 TRUE, 0, FALSE, 0)); 313 TRUE, 0, FALSE, 0));
314 } else { 314 } else {
315 asprintf (&data, "%s %s", data, 315 xasprintf (&data, "%s %s", data,
316 perfdata ("temp", (long)ups_temperature, tunits, 316 perfdata ("temp", (long)ups_temperature, tunits,
317 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 317 FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
318 } 318 }
@@ -321,7 +321,7 @@ main (int argc, char **argv)
321 /* if the UPS does not support any options we are looking for, report an error */ 321 /* if the UPS does not support any options we are looking for, report an error */
322 if (supported_options == UPS_NONE) { 322 if (supported_options == UPS_NONE) {
323 result = STATE_CRITICAL; 323 result = STATE_CRITICAL;
324 asprintf (&message, _("UPS does not support any available options\n")); 324 xasprintf (&message, _("UPS does not support any available options\n"));
325 } 325 }
326 326
327 /* reset timeout */ 327 /* reset timeout */
@@ -595,7 +595,7 @@ void
595print_help (void) 595print_help (void)
596{ 596{
597 char *myport; 597 char *myport;
598 asprintf (&myport, "%d", PORT); 598 xasprintf (&myport, "%d", PORT);
599 599
600 print_revision (progname, NP_VERSION); 600 print_revision (progname, NP_VERSION);
601 601
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 37662928..c581fb29 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -89,7 +89,7 @@ main (int argc, char **argv)
89 if (result == STATE_UNKNOWN) 89 if (result == STATE_UNKNOWN)
90 printf ("%s\n", _("Unable to read output")); 90 printf ("%s\n", _("Unable to read output"));
91 else { 91 else {
92 asprintf (&perf, "%s", perfdata ("users", users, "", 92 xasprintf (&perf, "%s", perfdata ("users", users, "",
93 TRUE, wusers, 93 TRUE, wusers,
94 TRUE, cusers, 94 TRUE, cusers,
95 TRUE, 0, 95 TRUE, 0,
diff --git a/plugins/negate.c b/plugins/negate.c
index 96f45578..493988ee 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -104,7 +104,7 @@ main (int argc, char **argv)
104 *sub = '\0'; 104 *sub = '\0';
105 sub += strlen (state_text (result)); 105 sub += strlen (state_text (result));
106 /* then put everything back together */ 106 /* then put everything back together */
107 asprintf (&chld_out.line[i], "%s%s%s", chld_out.line[i], state_text (state[result]), sub); 107 xasprintf (&chld_out.line[i], "%s%s%s", chld_out.line[i], state_text (state[result]), sub);
108 } 108 }
109 } 109 }
110 printf ("%s\n", chld_out.line[i]); 110 printf ("%s\n", chld_out.line[i]);
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 6bb42db0..30b2a353 100644
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
@@ -102,7 +102,7 @@ main (int argc, char **argv)
102 102
103 cmd = strdup (argv[optind++]); 103 cmd = strdup (argv[optind++]);
104 for (c = optind; c < argc; c++) { 104 for (c = optind; c < argc; c++) {
105 asprintf (&cmd, "%s %s", cmd, argv[c]); 105 xasprintf (&cmd, "%s %s", cmd, argv[c]);
106 } 106 }
107 107
108 child_process = spopen (cmd); 108 child_process = spopen (cmd);
diff --git a/plugins/utils.c b/plugins/utils.c
index 45373909..8827e31a 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -358,7 +358,7 @@ strscpy (char *dest, const char *src)
358 if (src == NULL) 358 if (src == NULL)
359 return NULL; 359 return NULL;
360 360
361 asprintf (&dest, "%s", src); 361 xasprintf (&dest, "%s", src);
362 362
363 return dest; 363 return dest;
364} 364}
@@ -513,6 +513,33 @@ strpcat (char *dest, const char *src, const char *str)
513 return dest; 513 return dest;
514} 514}
515 515
516
517/******************************************************************************
518 *
519 * asprintf, but die on failure
520 *
521 ******************************************************************************/
522
523int
524xvasprintf (char **strp, const char *fmt, va_list ap)
525{
526 int result = vasprintf (strp, fmt, ap);
527 if (result == -1 || *strp == NULL)
528 die (STATE_UNKNOWN, _("failed malloc in xvasprintf\n"));
529 return result;
530}
531
532int
533xasprintf (char **strp, const char *fmt, ...)
534{
535 va_list ap;
536 int result;
537 va_start (ap, fmt);
538 result = xvasprintf (strp, fmt, ap);
539 va_end (ap);
540 return result;
541}
542
516/****************************************************************************** 543/******************************************************************************
517 * 544 *
518 * Print perfdata in a standard format 545 * Print perfdata in a standard format
@@ -534,25 +561,25 @@ char *perfdata (const char *label,
534 char *data = NULL; 561 char *data = NULL;
535 562
536 if (strpbrk (label, "'= ")) 563 if (strpbrk (label, "'= "))
537 asprintf (&data, "'%s'=%ld%s;", label, val, uom); 564 xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
538 else 565 else
539 asprintf (&data, "%s=%ld%s;", label, val, uom); 566 xasprintf (&data, "%s=%ld%s;", label, val, uom);
540 567
541 if (warnp) 568 if (warnp)
542 asprintf (&data, "%s%ld;", data, warn); 569 xasprintf (&data, "%s%ld;", data, warn);
543 else 570 else
544 asprintf (&data, "%s;", data); 571 xasprintf (&data, "%s;", data);
545 572
546 if (critp) 573 if (critp)
547 asprintf (&data, "%s%ld;", data, crit); 574 xasprintf (&data, "%s%ld;", data, crit);
548 else 575 else
549 asprintf (&data, "%s;", data); 576 xasprintf (&data, "%s;", data);
550 577
551 if (minp) 578 if (minp)
552 asprintf (&data, "%s%ld", data, minv); 579 xasprintf (&data, "%s%ld", data, minv);
553 580
554 if (maxp) 581 if (maxp)
555 asprintf (&data, "%s;%ld", data, maxv); 582 xasprintf (&data, "%s;%ld", data, maxv);
556 583
557 return data; 584 return data;
558} 585}
@@ -573,29 +600,29 @@ char *fperfdata (const char *label,
573 char *data = NULL; 600 char *data = NULL;
574 601
575 if (strpbrk (label, "'= ")) 602 if (strpbrk (label, "'= "))
576 asprintf (&data, "'%s'=", label); 603 xasprintf (&data, "'%s'=", label);
577 else 604 else
578 asprintf (&data, "%s=", label); 605 xasprintf (&data, "%s=", label);
579 606
580 asprintf (&data, "%s%f", data, val); 607 xasprintf (&data, "%s%f", data, val);
581 asprintf (&data, "%s%s;", data, uom); 608 xasprintf (&data, "%s%s;", data, uom);
582 609
583 if (warnp) 610 if (warnp)
584 asprintf (&data, "%s%f", data, warn); 611 xasprintf (&data, "%s%f", data, warn);
585 612
586 asprintf (&data, "%s;", data); 613 xasprintf (&data, "%s;", data);
587 614
588 if (critp) 615 if (critp)
589 asprintf (&data, "%s%f", data, crit); 616 xasprintf (&data, "%s%f", data, crit);
590 617
591 asprintf (&data, "%s;", data); 618 xasprintf (&data, "%s;", data);
592 619
593 if (minp) 620 if (minp)
594 asprintf (&data, "%s%f", data, minv); 621 xasprintf (&data, "%s%f", data, minv);
595 622
596 if (maxp) { 623 if (maxp) {
597 asprintf (&data, "%s;", data); 624 xasprintf (&data, "%s;", data);
598 asprintf (&data, "%s%f", data, maxv); 625 xasprintf (&data, "%s%f", data, maxv);
599 } 626 }
600 627
601 return data; 628 return data;
diff --git a/plugins/utils.h b/plugins/utils.h
index 3c3f1892..822be940 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -81,6 +81,8 @@ char *strscpy (char *, const char *);
81char *strnl (char *); 81char *strnl (char *);
82char *strpcpy (char *, const char *, const char *); 82char *strpcpy (char *, const char *, const char *);
83char *strpcat (char *, const char *, const char *); 83char *strpcat (char *, const char *, const char *);
84int xvasprintf (char **strp, const char *fmt, va_list ap);
85int xasprintf (char **strp, const char *fmt, ...);
84 86
85int max_state (int a, int b); 87int max_state (int a, int b);
86int max_state_alt (int a, int b); 88int max_state_alt (int a, int b);