summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2006-01-10 07:53:22 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2006-01-10 07:53:22 +0000
commitca7fa1f7e97e09788ae091395435dd64ac8532c9 (patch)
treeaa4dfb81b5fed03016660841457f05d72303f55d
parent271c0769b0375246014162b7a160118465c5bbfe (diff)
downloadrsyslog-ca7fa1f7e97e09788ae091395435dd64ac8532c9.tar.gz
rsyslog-ca7fa1f7e97e09788ae091395435dd64ac8532c9.tar.xz
rsyslog-ca7fa1f7e97e09788ae091395435dd64ac8532c9.zip
enhanced legacy syslog message parser so that it supports messages without
a TIMESTAMP
-rw-r--r--NEWS2
-rw-r--r--syslogd.c54
2 files changed, 28 insertions, 28 deletions
diff --git a/NEWS b/NEWS
index 2f8b590f..947abb4b 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ Version 1.12.2 (RGer), 2005-12-??
- very (!) experimental support for syslog-protocol internet draft
added
- added support for field-extracting in the property replacer
+- enhanced the legacy-syslog parser so that it can interpret messages
+ that do not contain a TIMESTAMP
---------------------------------------------------------------------------
Version 1.12.1 (RGer), 2005-11-23
- made multithreading work with BSD. Some signal-handling needed to be
diff --git a/syslogd.c b/syslogd.c
index 2f7b4c07..9ec41500 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -4332,6 +4332,13 @@ static int parseRFCSyslogMsg(struct msg *pMsg, int flags)
* went wrong and this messe should be ignored. This function has been
* implemented in the effort to support syslog-protocol.
* rger, 2005-11-24
+ * As of 2006-01-10, I am removing the logic to continue parsing only
+ * when a valid TIMESTAMP is detected. Validity of other fields already
+ * is ignored. This is due to the fact that the parser has grown smarter
+ * and is now more able to understand different dialects of the syslog
+ * message format. I do not expect any bad side effects of this change,
+ * but I thought I log it in this comment.
+ * rgerhards, 2006-01-10
*/
static int parseLegacySyslogMsg(struct msg *pMsg, int flags)
{
@@ -4340,7 +4347,6 @@ static int parseLegacySyslogMsg(struct msg *pMsg, int flags)
char *pWork;
rsCStrObj *pStrB;
int iCnt;
- int bContParse = 1;
int bTAGCharDetected;
assert(pMsg != NULL);
@@ -4353,7 +4359,6 @@ static int parseLegacySyslogMsg(struct msg *pMsg, int flags)
if(srSLMGParseTIMESTAMP3164(&(pMsg->tTIMESTAMP), p2parse) == TRUE)
p2parse += 16;
else {
- bContParse = 0;
flags |= ADDDATE;
}
@@ -4380,33 +4385,26 @@ static int parseLegacySyslogMsg(struct msg *pMsg, int flags)
*/
bTAGCharDetected = 0;
if(pMsg->bParseHOSTNAME) {
- if(bContParse) {
- /* TODO: quick and dirty memory allocation */
- if((pBuf = malloc(sizeof(char)* strlen(p2parse) +1)) == NULL)
- return 1;
- pWork = pBuf;
- /* this is the actual parsing loop */
- while(*p2parse && *p2parse != ' ' && *p2parse != ':') {
- if( *p2parse == '[' || *p2parse == ']' || *p2parse == '/')
- bTAGCharDetected = 1;
- *pWork++ = *p2parse++;
- }
- /* we need to handle ':' seperately, because it terminates the
- * TAG - so we also need to terminate the parser here!
- */
- if(*p2parse == ':') {
+ /* TODO: quick and dirty memory allocation */
+ if((pBuf = malloc(sizeof(char)* strlen(p2parse) +1)) == NULL)
+ return 1;
+ pWork = pBuf;
+ /* this is the actual parsing loop */
+ while(*p2parse && *p2parse != ' ' && *p2parse != ':') {
+ if( *p2parse == '[' || *p2parse == ']' || *p2parse == '/')
bTAGCharDetected = 1;
- ++p2parse;
- } else if(*p2parse == ' ')
- ++p2parse;
- *pWork = '\0';
- MsgAssignHOSTNAME(pMsg, pBuf);
- } else {
- /* we can not parse, so we get the system we
- * received the data from.
- */
- MsgSetHOSTNAME(pMsg, getRcvFrom(pMsg));
+ *pWork++ = *p2parse++;
}
+ /* we need to handle ':' seperately, because it terminates the
+ * TAG - so we also need to terminate the parser here!
+ */
+ if(*p2parse == ':') {
+ bTAGCharDetected = 1;
+ ++p2parse;
+ } else if(*p2parse == ' ')
+ ++p2parse;
+ *pWork = '\0';
+ MsgAssignHOSTNAME(pMsg, pBuf);
}
/* check if we seem to have a TAG */
if(bTAGCharDetected) {
@@ -4435,7 +4433,7 @@ static int parseLegacySyslogMsg(struct msg *pMsg, int flags)
/* lol.. we tried to solve it, just to remind ourselfs that 32 octets
* is the max size ;) we need to shuffle the code again... Just for
* the records: the code is currently clean, but we could optimize it! */
- if(bContParse && !bTAGCharDetected) {
+ if(!bTAGCharDetected) {
char *pszTAG;
if((pStrB = rsCStrConstruct()) == NULL)
return 1;