diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-11-18 13:46:38 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-11-18 13:46:38 +0100 |
commit | afd425232f3198e7bb6f3dbcf0aa3cb4c24d5f7e (patch) | |
tree | 443837ad9da4771b5a55632a823b0696cc51118f /runtime/datetime.c | |
parent | ba2c160b320b5cc4dfb5190500237e09d8b5b54c (diff) | |
download | rsyslog-4.1.0.tar.gz rsyslog-4.1.0.tar.xz rsyslog-4.1.0.zip |
enhanced legacy syslog parser to detect year if part of the timestampv4.1.0
The format is based on what Cisco devices seem to emit.
Diffstat (limited to 'runtime/datetime.c')
-rw-r--r-- | runtime/datetime.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/runtime/datetime.c b/runtime/datetime.c index aa1956d7..676f76d5 100644 --- a/runtime/datetime.c +++ b/runtime/datetime.c @@ -312,6 +312,7 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, char** ppszTS) /* variables to temporarily hold time information while we parse */ int month; int day; + int year = 0; /* 0 means no year provided */ int hour; /* 24 hour clock */ int minute; int second; @@ -472,7 +473,23 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, char** ppszTS) if(*pszTS++ != ' ') ABORT_FINALIZE(RS_RET_INVLD_TIME); + + /* time part */ hour = srSLMGParseInt32(&pszTS); + if(hour > 1970 && hour < 2100) { + /* if so, we assume this actually is a year. This is a format found + * e.g. in Cisco devices. + * (if you read this 2100+ trying to fix a bug, congratulate myself + * to how long the code survived - me no longer ;)) -- rgerhards, 2008-11-18 + */ + year = hour; + + /* re-query the hour, this time it must be valid */ + if(*pszTS++ != ' ') + ABORT_FINALIZE(RS_RET_INVLD_TIME); + hour = srSLMGParseInt32(&pszTS); + } + if(hour < 0 || hour > 23) ABORT_FINALIZE(RS_RET_INVLD_TIME); @@ -502,6 +519,8 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, char** ppszTS) *ppszTS = pszTS; /* provide updated parse position back to caller */ pTime->timeType = 1; pTime->month = month; + if(year > 0) + pTime->year = year; /* persist year if detected */ pTime->day = day; pTime->hour = hour; pTime->minute = minute; |