From 43c45bfebcc672d6fbec2d4d659609d1ea48eda6 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 29 May 2009 13:40:04 +0200 Subject: fixed problem in syslog-protocol (now RFC5424) parser ... as well as some other minor issues. --- tools/syslogd.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'tools/syslogd.c') diff --git a/tools/syslogd.c b/tools/syslogd.c index 01d3af71..f8149613 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1252,21 +1252,26 @@ static int parseRFCStructuredData(char **pp2parse, char *pResult) if(*p2parse != '[') return 1; /* this is NOT structured data! */ - while(bCont) { - if(*p2parse == '\0') { - iRet = 1; /* this is not valid! */ - bCont = 0; - } else if(*p2parse == '\\' && *(p2parse+1) == ']') { - /* this is escaped, need to copy both */ - *pResult++ = *p2parse++; - *pResult++ = *p2parse++; - } else if(*p2parse == ']' && *(p2parse+1) == ' ') { - /* found end, just need to copy the ] and eat the SP */ - *pResult++ = *p2parse; - p2parse += 2; - bCont = 0; - } else { - *pResult++ = *p2parse++; + if(*p2parse != '-') { /* empty structured data? */ + *pResult++ = '-'; + ++p2parse; + } else { + while(bCont) { + if(*p2parse == '\0') { + iRet = 1; /* this is not valid! */ + bCont = 0; + } else if(*p2parse == '\\' && *(p2parse+1) == ']') { + /* this is escaped, need to copy both */ + *pResult++ = *p2parse++; + *pResult++ = *p2parse++; + } else if(*p2parse == ']' && *(p2parse+1) == ' ') { + /* found end, just need to copy the ] and eat the SP */ + *pResult++ = *p2parse; + p2parse += 2; + bCont = 0; + } else { + *pResult++ = *p2parse++; + } } } -- cgit