diff options
author | Thomas D <whissi@whissi.de> | 2016-03-12 03:51:55 +0100 |
---|---|---|
committer | Ian Delaney <idella4@gentoo.org> | 2016-03-12 12:31:31 +0800 |
commit | 968a7ec803b82b4018724e268bc2a475e4c98a4c (patch) | |
tree | 5c31f38efc42ecb03594f147032760232820bd3e /app-admin/rsyslog/files | |
parent | dev-libs/expat: 2.1.1 (diff) | |
download | gentoo-968a7ec803b82b4018724e268bc2a475e4c98a4c.tar.gz gentoo-968a7ec803b82b4018724e268bc2a475e4c98a4c.tar.bz2 gentoo-968a7ec803b82b4018724e268bc2a475e4c98a4c.zip |
app-admin/rsyslog: Rev bump to fix a leap year issue
Bug: https://github.com/rsyslog/rsyslog/issues/830
Package-Manager: portage-2.2.28
Closes: https://github.com/gentoo/gentoo/pull/1034
Diffstat (limited to 'app-admin/rsyslog/files')
-rw-r--r-- | app-admin/rsyslog/files/8-stable/50-rsyslog-8.16.0-fix-leap-year-handling.patch | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/app-admin/rsyslog/files/8-stable/50-rsyslog-8.16.0-fix-leap-year-handling.patch b/app-admin/rsyslog/files/8-stable/50-rsyslog-8.16.0-fix-leap-year-handling.patch new file mode 100644 index 000000000000..6cf8fa667f3f --- /dev/null +++ b/app-admin/rsyslog/files/8-stable/50-rsyslog-8.16.0-fix-leap-year-handling.patch @@ -0,0 +1,86 @@ +From ffb321f1698a971e0acda48cafa97bb344cf0829 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards <rgerhards@adiscon.com> +Date: Wed, 2 Mar 2016 11:43:09 +0100 +Subject: [PATCH] bugfix: unixtimestamp was incorrectly computed + +The problem happened in leap year from March til then end +of year and healed itself at the begining of the next year. +During the problem period, the timestamp was 24 hours too +low. + +This is primarily a simple fix that can also be applied to +older rsyslog versions. However, we will see if we can +refactor the code to make use of mktime(). Originally, that +was not done for some issues seen, which may no longer +apply. + +fixes https://github.com/rsyslog/rsyslog/issues/830 +--- + runtime/datetime.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/runtime/datetime.c b/runtime/datetime.c +index efb4c81..a07c1b7 100644 +--- a/runtime/datetime.c ++++ b/runtime/datetime.c +@@ -1054,6 +1054,11 @@ time_t syslogTime2time_t(struct syslogTime *ts) + MonthInDays = 0; /* any value fits ;) */ + break; + } ++ /* adjust for leap years */ ++ if((ts->year % 100 != 0 && ts->year % 4 == 0) || (ts->year == 2000)) { ++ if(ts->month > 2) ++ MonthInDays++; ++ } + + + /* 1) Counting how many Years have passed since 1970 +@@ -1064,7 +1069,7 @@ time_t syslogTime2time_t(struct syslogTime *ts) + + NumberOfYears = ts->year - yearInSec_startYear - 1; + NumberOfDays = MonthInDays + ts->day - 1; +- TimeInUnixFormat = yearInSecs[NumberOfYears] + NumberOfDays * 86400; ++ TimeInUnixFormat = (yearInSecs[NumberOfYears] + 1) + NumberOfDays * 86400; + + /*Add Hours, minutes and seconds */ + TimeInUnixFormat += ts->hour*60*60; +From 5cb41f748329986d5e2aa8d5e87f224bb9cb8234 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards <rgerhards@adiscon.com> +Date: Wed, 2 Mar 2016 15:58:18 +0100 +Subject: [PATCH] timestamp handling: guard against invalid dates + +We do not permit dates outside of the year 1970..2100 +interval. Note that network-receivers do already guard +against this, so the new guard only guards against invalid +system time. Still good to have (especially when things are +extended...) +--- + runtime/datetime.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/runtime/datetime.c b/runtime/datetime.c +index 9641363..87290c9 100644 +--- a/runtime/datetime.c ++++ b/runtime/datetime.c +@@ -1023,6 +1023,13 @@ time_t syslogTime2time_t(struct syslogTime *ts) + int utcOffset; + time_t TimeInUnixFormat; + ++ if(ts->year < 1970 || ts->year > 2100) { ++ TimeInUnixFormat = 0; ++ errmsg.LogError(0, RS_RET_ERR, "syslogTime2time_t: invalid year %d " ++ "in timestamp - returning 1970-01-01 instead", ts->year); ++ goto done; ++ } ++ + /* Counting how many Days have passed since the 01.01 of the + * selected Year (Month level), according to the selected Month*/ + +@@ -1096,6 +1103,7 @@ time_t syslogTime2time_t(struct syslogTime *ts) + if(ts->OffsetMode == '+') + utcOffset *= -1; /* if timestamp is ahead, we need to "go back" to UTC */ + TimeInUnixFormat += utcOffset; ++done: + return TimeInUnixFormat; + } + |