summaryrefslogtreecommitdiff
path: root/msg.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2008-03-29 12:14:30 +0100
committerMichael Biebl <biebl@debian.org>2008-03-29 12:14:30 +0100
commit2bff2e5d72345617f3b3e394ff28823067024f7a (patch)
treefa75d6280610ecf79f5c054e6d68e35b27c638c6 /msg.c
parent45e27e9006d03436f21a47ed2a0b283503fa2d80 (diff)
downloadrsyslog-2bff2e5d72345617f3b3e394ff28823067024f7a.tar.gz
Imported Upstream version 1.19.3upstream/1.19.3
Diffstat (limited to 'msg.c')
-rw-r--r--msg.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/msg.c b/msg.c
index 30fe7d4..be3c48a 100644
--- a/msg.c
+++ b/msg.c
@@ -1606,6 +1606,45 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
}
}
+ /* Take care of spurious characters to make the property safe
+ * for a path definition
+ */
+ if(pTpe->data.field.options.bSecPathDrop || pTpe->data.field.options.bSecPathReplace) {
+ if(pTpe->data.field.options.bSecPathDrop) {
+ char *pSrc = pRes;
+ char *pDst = pRes;
+ while(*pSrc) {
+ if(*pSrc != '/')
+ *pDst++ = *pSrc;
+ pSrc++;
+ }
+ *pDst = '\0';
+ } else {
+ char *pB = pRes;
+ while(*pB) {
+ if(*pB == '/')
+ *pB = '_';
+ pB++;
+ }
+ }
+
+ if(*pRes == '.' && (*(pRes + 1) == '\0' || (*(pRes + 1) == '.' && *(pRes + 2) == '\0')))
+ *pRes = '_';
+
+ if(*pRes == '\0') {
+ if(*pbMustBeFreed == 1)
+ free(pRes);
+ pRes = malloc(2);
+ if(pRes == NULL) {
+ *pbMustBeFreed = 0;
+ return "**OUT OF MEMORY ALLOCATING pBuf**";
+ }
+ *pRes = '_';
+ *(pRes + 1) = '\0';
+ *pbMustBeFreed = 1;
+ }
+ }
+
/* Now drop last LF if present (pls note that this must not be done
* if bEscapeCC was set!
*/