Просмотр исходного кода

In the CHECK_COUNTER block, there were several strcats writing to unallocated
memory. Changed to asprintf. We're not freeing since plugin run is short.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1085 f882894a-f735-0410-b71e-b25c423dba1c

Harper Mann 21 лет назад
Родитель
Сommit
3f0fd90ba8
1 измененных файлов с 7 добавлено и 8 удалено
  1. 7 8
      plugins/check_nt.c

+ 7 - 8
plugins/check_nt.c

@@ -355,19 +355,18 @@ int main(int argc, char **argv){
 	  		if (allRight)
 	    		{
 	      			/* Let's format the output string, finally... */
-
 					if (strstr(description, "%") == NULL) {
-						asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
+						asprintf (&output_message, "%s = %.2f %s", 											description, counter_value, counter_unit);
 					} else {
 						/* has formatting, will segv if wrong */
 	      				asprintf (&output_message, description, counter_value);
 					}
-	      			output_message = strcat (output_message, "|");
-	      			output_message = strcat (output_message,
-							fperfdata (description, counter_value, counter_unit,
-				   				   1, warning_value, 1, critical_value,
-				   				   (!(isPercent) && (minval != NULL)), fminval,
-				   				   (!(isPercent) && (minval != NULL)), fmaxval));
+					asprintf (&output_message, "%s |", output_message);
+	      			asprintf (&output_message,"%s %s", output_message, 
+						fperfdata (description, counter_value, 
+							counter_unit, 1, warning_value, 1, critical_value,
+				   			(!(isPercent) && (minval != NULL)), fminval,
+				   			(!(isPercent) && (minval != NULL)), fmaxval));
 	    		}
 		}