Code

Fix check_time returning wrong OK when time is before the epoch on some arch
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>
Wed, 2 May 2007 05:22:31 +0000 (05:22 +0000)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>
Wed, 2 May 2007 05:22:31 +0000 (05:22 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1703 f882894a-f735-0410-b71e-b25c423dba1c

NEWS
THANKS.in
plugins/check_time.c

diff --git a/NEWS b/NEWS
index eb84e0fa49b85beaceecf5909eb80ab680379081..88d8ea29cb9ab19bf3e2a84cab0492cdaed3585b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases.
        check_snmp now support Counter64
        Fix compilation of check_ldap, check_radius and check_pgsql
        check_load can optionally divide by number of cpus
+        Fix check_time returning wrong OK when time is before the epoch on some arch
 
 1.4.8 11th April 2007
        Respects --without-world-permissions for setuid plugins
index f75626807cebb96148e0e3bb6c87bfea2f14d242..c9d604b4bf5d529326cbc3b3f2377479179b8856 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
@@ -216,3 +216,4 @@ Stefan Meier
 Mark Favas
 Felix Frank
 Denis Knauf
+Matthias Flacke
index d3af3b0cef944242fb97055e5455620c935fea7c..581c42a318b3147170e8786cf132728b26c2c2d6 100644 (file)
@@ -49,8 +49,8 @@ enum {
 
 #define        UNIX_EPOCH 2208988800UL
 
-uint32_t server_time, raw_server_time;
-time_t diff_time;
+uint32_t raw_server_time;
+unsigned long server_time, diff_time;
 int warning_time = 0;
 int check_warning_time = FALSE;
 int critical_time = 0;
@@ -166,9 +166,9 @@ main (int argc, char **argv)
        else
                diff_time = (unsigned long)end_time - server_time;
 
-       if (check_critical_diff == TRUE && diff_time > (time_t)critical_diff)
+       if (check_critical_diff == TRUE && diff_time > critical_diff)
                result = STATE_CRITICAL;
-       else if (check_warning_diff == TRUE && diff_time > (time_t)warning_diff)
+       else if (check_warning_diff == TRUE && diff_time > warning_diff)
                result = STATE_WARNING;
 
        printf (_("TIME %s - %lu second time difference|%s %s\n"),
@@ -177,9 +177,9 @@ main (int argc, char **argv)
                          check_warning_time, (long)warning_time,
                          check_critical_time, (long)critical_time,
                          TRUE, 0, FALSE, 0),
-               perfdata ("offset", (long)diff_time, "s",
-                         check_warning_diff, (long)warning_diff,
-                         check_critical_diff, (long)critical_diff,
+               perfdata ("offset", diff_time, "s",
+                         check_warning_diff, warning_diff,
+                         check_critical_diff, critical_diff,
                          TRUE, 0, FALSE, 0));
        return result;
 }