[Nagiosplug-checkins] nagiosplug/plugins check_nt.c,1.38,1.39
Harper Mann
harpermann at users.sourceforge.net
Wed Jan 19 15:41:39 CET 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12188
Modified Files:
check_nt.c
Log Message:
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.
Index: check_nt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nt.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- check_nt.c 25 Dec 2004 23:17:44 -0000 1.38
+++ check_nt.c 19 Jan 2005 23:39:45 -0000 1.39
@@ -355,19 +355,18 @@
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));
}
}
More information about the Commits
mailing list