summaryrefslogtreecommitdiffstats
path: root/plugins/imfile
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-12 08:20:23 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-12 08:20:23 +0000
commit7bd24b3576dc085db1c15d40428a238809a912c1 (patch)
treef027a6206554bd5709a5d5b57e17dd4858ae927e /plugins/imfile
parentb1555cd681652e57f76449e39cb1aae8db7d601b (diff)
downloadrsyslog-7bd24b3576dc085db1c15d40428a238809a912c1.tar.gz
rsyslog-7bd24b3576dc085db1c15d40428a238809a912c1.tar.xz
rsyslog-7bd24b3576dc085db1c15d40428a238809a912c1.zip
bugfix: rsyslogd segfaulted when imfile read an empty line - thanks to
Johnny Tan for an excellent bug report
Diffstat (limited to 'plugins/imfile')
-rw-r--r--plugins/imfile/imfile.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index c65fc436..b431fbbc 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -81,20 +81,25 @@ static fileInfo_t files[MAX_INPUT_FILES];
*/
static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
{
- DEFiRet;
- msg_t *pMsg;
-
- CHKiRet(msgConstruct(&pMsg));
- MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetHOSTNAME(pMsg, LocalHostName);
- MsgSetTAG(pMsg, (char*)pInfo->pszTag);
- pMsg->iFacility = LOG_FAC(pInfo->iFacility);
- pMsg->iSeverity = LOG_PRI(pInfo->iSeverity);
- pMsg->bParseHOSTNAME = 0;
- datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */
- CHKiRet(submitMsg(pMsg));
+ DEFiRet;
+ msg_t *pMsg;
+
+ if(rsCStrLen(cstrLine) == 0) {
+ /* we do not process empty lines */
+ FINALIZE;
+ }
+
+ CHKiRet(msgConstruct(&pMsg));
+ MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
+ MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
+ MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
+ MsgSetHOSTNAME(pMsg, LocalHostName);
+ MsgSetTAG(pMsg, (char*)pInfo->pszTag);
+ pMsg->iFacility = LOG_FAC(pInfo->iFacility);
+ pMsg->iSeverity = LOG_PRI(pInfo->iSeverity);
+ pMsg->bParseHOSTNAME = 0;
+ datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */
+ CHKiRet(submitMsg(pMsg));
finalize_it:
RETiRet;
}