Blob Blame History Raw
From 177a4863f016fae5640fffd6b6ff8f86b5ffee3a Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <theinric@redhat.com>
Date: Mon, 28 Jul 2014 18:39:06 +0200
Subject: [PATCH] imjournal: sanitize messages as imuxsock does it

This change makes these directives available for imjournal:
  $ControlCharacterEscapePrefix
  $DropTrailingLFOnReception
  $Escape8bitCharactersOnReceive
  $EscapeControlCharacterTab
  $EscapeControlCharactersOnReceive
  $SpaceNLOnReceive
---
 plugins/imjournal/imjournal.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
index 7d42b84..b0b034c 100755
--- a/plugins/imjournal/imjournal.c
+++ b/plugins/imjournal/imjournal.c
@@ -44,6 +44,7 @@
 #include "imjournal.h"
 #include "net.h"
 #include "glbl.h"
+#include "parser.h"
 #include "prop.h"
 #include "errmsg.h"
 #include "srUtils.h"
@@ -58,6 +59,7 @@ MODULE_CNFNAME("imjournal")
 DEF_IMOD_STATIC_DATA
 DEFobjCurrIf(datetime)
 DEFobjCurrIf(glbl)
+DEFobjCurrIf(parser)
 DEFobjCurrIf(prop)
 DEFobjCurrIf(net)
 DEFobjCurrIf(errmsg)
@@ -142,6 +144,7 @@ enqMsg(uchar *msg, uchar *pszTag, int iFacility, int iSeverity, struct timeval *
 {
 	struct syslogTime st;
 	msg_t *pMsg;
+	size_t len;
 	DEFiRet;
 
 	assert(msg != NULL);
@@ -155,7 +158,10 @@ enqMsg(uchar *msg, uchar *pszTag, int iFacility, int iSeverity, struct timeval *
 	}
 	MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
 	MsgSetInputName(pMsg, pInputName);
-	MsgSetRawMsgWOSize(pMsg, (char*)msg);
+	len = strlen((char*)msg);
+	MsgSetRawMsg(pMsg, (char*)msg, len);
+	if(len > 0)
+		parser.SanitizeMsg(pMsg);
 	MsgSetMSGoffs(pMsg, 0);	/* we do not have a header... */
 	MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
 	MsgSetRcvFromIP(pMsg, pLocalHostIP);
@@ -670,6 +676,7 @@ CODESTARTmodExit
 	objRelease(glbl, CORE_COMPONENT);
 	objRelease(net, CORE_COMPONENT);
 	objRelease(datetime, CORE_COMPONENT);
+	objRelease(parser, CORE_COMPONENT);
 	objRelease(prop, CORE_COMPONENT);
 	objRelease(errmsg, CORE_COMPONENT);
 ENDmodExit
@@ -750,6 +757,7 @@ CODESTARTmodInit
 CODEmodInit_QueryRegCFSLineHdlr
 	CHKiRet(objUse(datetime, CORE_COMPONENT));
 	CHKiRet(objUse(glbl, CORE_COMPONENT));
+	CHKiRet(objUse(parser, CORE_COMPONENT));
 	CHKiRet(objUse(prop, CORE_COMPONENT));
 	CHKiRet(objUse(net, CORE_COMPONENT));
 	CHKiRet(objUse(errmsg, CORE_COMPONENT));
-- 
1.9.3