[icinga-checkins] icinga.org: icinga2/master: Fix: "day -X" time specifications are parsed incorrectly

git at icinga.org git at icinga.org
Wed May 11 09:26:21 CEST 2016


Module: icinga2
Branch: master
Commit: ed2713040275c2881cfc7fc0a40f9d5117930e0b
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=ed2713040275c2881cfc7fc0a40f9d5117930e0b

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed May 11 09:23:55 2016 +0200

Fix: "day -X" time specifications are parsed incorrectly

fixes #11147

---

 lib/icinga/legacytimeperiod.cpp |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/icinga/legacytimeperiod.cpp b/lib/icinga/legacytimeperiod.cpp
index 267fb67..2c08394 100644
--- a/lib/icinga/legacytimeperiod.cpp
+++ b/lib/icinga/legacytimeperiod.cpp
@@ -150,6 +150,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
 			BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid day in time specification: " + timespec));
 
 		if (begin) {
+			*begin = *reference;
 			begin->tm_year = year - 1900;
 			begin->tm_mon = month - 1;
 			begin->tm_mday = day;
@@ -159,6 +160,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
 		}
 
 		if (end) {
+			*end = *reference;
 			end->tm_year = year - 1900;
 			end->tm_mon = month - 1;
 			end->tm_mday = day;
@@ -191,7 +193,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
 
 			/* Negative days are relative to the next month. */
 			if (mday < 0) {
-				end->tm_mday--;
+				begin->tm_mday = mday * -1 - 1;
 				begin->tm_mon++;
 			}
 		}
@@ -206,7 +208,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
 
 			/* Negative days are relative to the next month. */
 			if (mday < 0) {
-				end->tm_mday--;
+				end->tm_mday = mday * -1 - 1;
 				end->tm_mon++;
 			}
 		}



More information about the icinga-checkins mailing list