]> granicus.if.org Git - icinga2/commitdiff
Fix validation errors for time ranges which span the DST transition
authorGunnar Beutner <gunnar@beutner.name>
Sun, 29 Mar 2015 06:05:01 +0000 (08:05 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 29 Mar 2015 06:18:01 +0000 (08:18 +0200)
fixes #8892

lib/icinga/legacytimeperiod.cpp

index d78cc00f4d4b3389e0641d8961d7bc1094710421..b346d3bc0011c5eaa746819aa5ee8afb916ee0b0 100644 (file)
@@ -371,6 +371,10 @@ void LegacyTimePeriod::ProcessTimeRangeRaw(const String& timerange, tm *referenc
        end->tm_sec = 0;
        end->tm_min = Convert::ToLong(hd2[1]);
        end->tm_hour = Convert::ToLong(hd2[0]);
+
+       if (begin->tm_hour * 3600 + begin->tm_min * 60 + begin->tm_sec >=
+           end->tm_hour * 3600 + end->tm_min * 60 + end->tm_sec)
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Time period segment ends before it begins"));
 }
 
 Dictionary::Ptr LegacyTimePeriod::ProcessTimeRange(const String& timestamp, tm *reference)
@@ -404,7 +408,7 @@ void LegacyTimePeriod::ProcessTimeRanges(const String& timeranges, tm *reference
                }
 
                if (segment->Get("begin") >= segment->Get("end"))
-                       BOOST_THROW_EXCEPTION(std::invalid_argument("Time period segment ends before it begins"));
+                       continue;
 
                result->Add(segment);
        }