[checkmk-commits] Check_MK Git: check_mk: livecheck: call check_icmp with correct output buffer size

git version control git at mathias-kettner.de
Sat Nov 10 23:49:43 CET 2012


Module: check_mk
Branch: master
Commit: 630bbf2733e095ce57d270ec74ea3b08617c744f
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=630bbf2733e095ce57d270ec74ea3b08617c744f

Author: Andreas Boesl <ab at mathias-kettner.de>
Date:   Sat Nov 10 23:46:03 2012 +0100

livecheck: call check_icmp with correct output buffer size

---

 ChangeLog                   |    1 +
 livestatus/src/check_icmp.c |    2 +-
 livestatus/src/livecheck.c  |    4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ec3f7aa..262bf89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -142,6 +142,7 @@
            -> preventing possible freeze of livecheck
     * FIX: correct escaping of character / in nagios checkresult file
     * FIX: fixed SIGSEGV on hosts without defined check_command
+    * FIX: now providing correct output buffer size when calling check_icmp 
 
     Checks & Agents:
     * FIX: Linux mk_logwatch: iregex Parameter was never used
diff --git a/livestatus/src/check_icmp.c b/livestatus/src/check_icmp.c
index fb015e7..a2784e6 100644
--- a/livestatus/src/check_icmp.c
+++ b/livestatus/src/check_icmp.c
@@ -242,7 +242,7 @@ void do_output(int crash, char *format, ...)
 {
     va_list ap;
     va_start(ap, format);
-    int place_left = g_output_buffer + g_output_buffer_size - g_output_pointer;
+    int place_left = g_output_buffer + g_output_buffer_size - g_output_pointer - 1;
     g_output_pointer += vsnprintf(g_output_pointer, place_left, format, ap);
     va_end(ap);
     *g_output_pointer = 0;
diff --git a/livestatus/src/livecheck.c b/livestatus/src/livecheck.c
index 461a08a..019613a 100644
--- a/livestatus/src/livecheck.c
+++ b/livestatus/src/livecheck.c
@@ -37,7 +37,7 @@ pid_t g_pid;
 static void alarm_handler(int);
 static void term_handler(int);
 static char **parse_into_arguments(char *command);
-int check_icmp(int argc, char **argv, char *output);
+int check_icmp(int argc, char **argv, char *output, int size);
 int icmp_sock = -1;
 
 // This program must be called with two arguments:
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
             int arg_c = 0;
             while (arguments[arg_c])
                 arg_c++;
-            return_code = check_icmp(arg_c, arguments, output);
+            return_code = check_icmp(arg_c, arguments, output, sizeof(output));
         }
         else {
             int fd[2];



More information about the checkmk-commits mailing list