summaryrefslogtreecommitdiffstats
path: root/web/attachments/36789-NSClient-1.07.0_1.patch
blob: 7ce4552712f6b30ea5da76868640293bc6d67d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
diff -uNr NSClient-1.07.0.orig/UnixSource/check_nt.c NSClient-1.07.0/UnixSource/check_nt.c
--- NSClient-1.07.0.orig/UnixSource/check_nt.c	Sun Feb 24 14:55:48 2002
+++ NSClient-1.07.0/UnixSource/check_nt.c	Wed Nov 27 12:10:46 2002
@@ -95,7 +95,7 @@
 	int updays=0;
 	int uphours=0;
 	int upminutes=0;
-	req_password=strscpy(req_password,"None");
+	asprintf(&req_password,"None");
 
 	if(process_arguments(argc,argv)==ERROR)
 		usage("Could not parse arguments\n");
@@ -108,11 +108,11 @@
 
 	if (vars_to_check==CHECK_CLIENTVERSION) {
 			
-		send_buffer = strscpy(send_buffer,strcat(req_password,"&1"));
+		asprintf(&send_buffer,strcat(req_password,"&1"));
 		result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if(result!=STATE_OK)
 			return result;
-		output_message = strscpy(output_message,recv_buffer);
+		asprintf(&output_message,recv_buffer);
 		return_code=STATE_OK;
 	}
 	else if(vars_to_check==CHECK_CPULOAD){
@@ -121,14 +121,14 @@
 			if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
 				// -l parameters is present with only integers
 				return_code=STATE_OK;
-				temp_string = strscpy(temp_string,"CPU Load");
+				asprintf(&temp_string,"CPU Load");
 				while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 && 
 							lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 && 
 							lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) {
 					// loop until one of the parameters is wrong or not present
 
 					// Send request and retrieve data
-					send_buffer = ssprintf(send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
+					asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
 					result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 					if(result!=STATE_OK)
 						return result;
@@ -146,27 +146,27 @@
 					else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
 						return_code=STATE_WARNING;
 
-					output_message = ssprintf(output_message," (%lu min. %lu%)",lvalue_list[0+offset], utilization);
-					temp_string = strscat(temp_string,output_message);
+					asprintf(&output_message," (%lu min. %lu%)",lvalue_list[0+offset], utilization);
+					asprintf(&temp_string,"%s%s",temp_string,output_message);
 					offset+=3;	//move accross the array 
 				}		
 				if (strlen(temp_string)>10) {
 					// we had at least on loop
-					output_message = ssprintf(output_message,"%s",temp_string);
+					asprintf(&output_message,"%s",temp_string);
 				}	
 				else
-					output_message = strscpy(output_message,"not enough values for -l parameters");
+					asprintf(&output_message,"%s","not enough values for -l parameters");
 					
 			} else 
-				output_message = strscpy(output_message,"wrong -l parameter.");
+				asprintf(&output_message,"wrong -l parameter.");
 
 		} else
-			output_message = strscpy(output_message,"missing -l parameters");
+			asprintf(&output_message,"missing -l parameters");
 	}
 
 	else if(vars_to_check==CHECK_UPTIME){
 
-		send_buffer = strscpy(send_buffer,strcat(req_password,"&3"));
+		asprintf(&send_buffer,strcat(req_password,"&3"));
 		result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if(result!=STATE_OK)
 			return result;
@@ -180,7 +180,7 @@
 		updays = uptime / 86400; 			
 		uphours = (uptime % 86400) / 3600;
 		upminutes = ((uptime % 86400) % 3600) / 60;
-		output_message = ssprintf(output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes);
+		asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes);
 		return_code=STATE_OK;
 	}
 
@@ -189,7 +189,7 @@
 		return_code=STATE_UNKNOWN;	
 		if (check_value_list==TRUE) {
 			if (strlen(value_list)==1) {
-				send_buffer = ssprintf(send_buffer,"%s&4&%s", req_password, value_list);
+				asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
 				result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 				if(result!=STATE_OK)
 					return result;
@@ -204,7 +204,7 @@
 				percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
 
 				if (free_disk_space>=0) {
-					temp_string = ssprintf(temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)",
+					asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)",
 							value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
 							 free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 
 
@@ -216,18 +216,18 @@
 					else
 						return_code=STATE_OK;	
 
-					output_message = ssprintf(output_message,"%s",temp_string);
+					asprintf(&output_message,"%s",temp_string);
 
 				}
 				else {
-					output_message = ssprintf(output_message,"Free disk space : Invalid drive ");
+					asprintf(&output_message,"Free disk space : Invalid drive ");
 					return_code=STATE_UNKNOWN;
 				}		
 			}
 			else 
-				output_message = strscpy(output_message,"wrong -l argument");
+				asprintf(&output_message,"wrong -l argument");
 		} else 
-			output_message = strscpy(output_message,"missing -l parameters");
+			asprintf(&output_message,"missing -l parameters");
 			
 	}
 
@@ -235,7 +235,7 @@
 
 		if (check_value_list==TRUE) {
 			preparelist(value_list);		// replace , between services with & to send the request
-			send_buffer = ssprintf(send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
+			asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
 				(show_all==TRUE)?"ShowAll":"ShowFail",value_list);
 			result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 			if(result!=STATE_OK)
@@ -247,15 +247,15 @@
 			}
 			return_code=atoi(strtok(recv_buffer,"&"));
 			temp_string=strtok(NULL,"&");
-			output_message = ssprintf(output_message, "%s",temp_string);
+			asprintf(&output_message, "%s",temp_string);
 		}
 		else 
-			output_message = strscpy(output_message,"No service/process specified");
+			asprintf(&output_message,"No service/process specified");
 	}
 
 	else if(vars_to_check==CHECK_MEMUSE) {
 		
-		send_buffer = ssprintf(send_buffer,"%s&7", req_password);
+		asprintf(&send_buffer,"%s&7", req_password);
 		result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
 			return result;
@@ -268,7 +268,7 @@
 		mem_commitLimit=atof(strtok(recv_buffer,"&"));
 		mem_commitByte=atof(strtok(NULL,"&"));
 		percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
-		output_message = ssprintf(output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)", 
+		asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)", 
 			mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,  
 			(mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
 	
@@ -285,7 +285,7 @@
 
 		if (check_value_list==TRUE) {																			
 			preparelist(value_list);		// replace , between services with & to send the request
-			send_buffer = ssprintf(send_buffer,"%s&8&%s", req_password,value_list);
+			asprintf(&send_buffer,"%s&8&%s", req_password,value_list);
 			result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 			if (result!=STATE_OK)
 				return result;
@@ -299,9 +299,9 @@
 			description = strtok(NULL,"&");
 			counter_value = atof(recv_buffer);
 			if (description == NULL) 
-				output_message = ssprintf(output_message, "%.f", counter_value);
+				asprintf(&output_message, "%.f", counter_value);
 			else
-				output_message = ssprintf(output_message, description, counter_value);
+				asprintf(&output_message, description, counter_value);
 	
 			if (critical_value > warning_value) {
 				// Normal thresholds		
@@ -324,7 +324,7 @@
 		
 		}
 		else {
-			output_message = strscpy(output_message,"No counter specified");
+			asprintf(&output_message,"No counter specified");
 			result=STATE_UNKNOWN;
 		}
 	}
@@ -332,7 +332,7 @@
 
 		if (check_value_list==TRUE) {																			
 			preparelist(value_list);		// replace , between services with & to send the request
-			send_buffer = ssprintf(send_buffer,"%s&9&%s", req_password,value_list);
+			asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
 			result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
 			if (result!=STATE_OK)
 				return result;
@@ -344,7 +344,7 @@
 
 			age_in_minutes = atoi(strtok(recv_buffer,"&"));
 			description = strtok(NULL,"&");
-			output_message = ssprintf(output_message, description);
+			asprintf(&output_message, description);
 	
 			if (critical_value > warning_value) {
 				// Normal thresholds		
@@ -367,7 +367,7 @@
 		
 		}
 		else {
-			output_message = strscpy(output_message,"No file specified");
+			asprintf(&output_message,"No file specified");
 			result=STATE_UNKNOWN;
 		}
 	}
@@ -447,7 +447,7 @@
 				server_address=optarg;
 				break;
 			case 's': /* password */
-				req_password=strscpy(req_password,optarg);
+				asprintf(&req_password,optarg);
 				break;
 			case 'p': /* port */
 				if (is_intnonneg(optarg))
@@ -480,7 +480,7 @@
 					return ERROR;
 				break;
 			case 'l': /* value list */
-				value_list=strscpy(value_list,optarg);
+				asprintf(&value_list,optarg);
 				check_value_list=TRUE;
 				break;
 			case 'w': /* warning threshold */