diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/msg.c | 27 | ||||
-rw-r--r-- | runtime/msg.h | 1 | ||||
-rw-r--r-- | runtime/rsyslog.h | 1 |
3 files changed, 7 insertions, 22 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 2ff63d9c..1a864648 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1303,19 +1303,6 @@ static inline char *getMSGID(msg_t *pM) } -/* Set the TAG to a caller-provided string. This is thought - * to be a heap buffer that the caller will no longer use. This - * function is a performance optimization over MsgSetTAG(). - * rgerhards 2004-11-19 - */ -void MsgAssignTAG(msg_t *pMsg, uchar *pBuf) -{ - assert(pMsg != NULL); - MsgSetTAG(pMsg, pBuf, ustrlen(pBuf)); - free(pBuf); -} - - /* rgerhards 2009-06-12: set associated ruleset */ void MsgSetRuleset(msg_t *pMsg, ruleset_t *pRuleset) @@ -1361,10 +1348,10 @@ void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf) * if there is a TAG and, if not, if it can emulate it. * rgerhards, 2005-11-24 */ -static void tryEmulateTAG(msg_t *pM) +static inline void tryEmulateTAG(msg_t *pM) { - int iTAGLen; - uchar *pBuf; + size_t lenTAG; + uchar bufTAG[CONF_TAG_MAXSIZE]; assert(pM != NULL); if(pM->iLenTAG > 0) @@ -1376,11 +1363,9 @@ static void tryEmulateTAG(msg_t *pM) MsgSetTAG(pM, (uchar*) getAPPNAME(pM), getAPPNAMELen(pM)); } else { /* now we can try to emulate */ - iTAGLen = getAPPNAMELen(pM) + getPROCIDLen(pM) + 3; - if((pBuf = malloc(iTAGLen * sizeof(char))) == NULL) - return; /* nothing we can do */ - snprintf((char*)pBuf, iTAGLen, "%s[%s]", getAPPNAME(pM), getPROCID(pM)); - MsgAssignTAG(pM, pBuf); + lenTAG = snprintf((char*)bufTAG, CONF_TAG_MAXSIZE, "%s[%s]", getAPPNAME(pM), getPROCID(pM)); + bufTAG[32] = '\0'; /* just to make sure... */ + MsgSetTAG(pM, bufTAG, lenTAG); } } } diff --git a/runtime/msg.h b/runtime/msg.h index 34983704..0f9bd95e 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -145,7 +145,6 @@ void MsgSetInputName(msg_t *pMsg, uchar*, size_t); rsRetVal MsgSetAPPNAME(msg_t *pMsg, char* pszAPPNAME); rsRetVal MsgSetPROCID(msg_t *pMsg, char* pszPROCID); rsRetVal MsgSetMSGID(msg_t *pMsg, char* pszMSGID); -void MsgAssignTAG(msg_t *pMsg, uchar *pBuf); void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf); void MsgSetRuleset(msg_t *pMsg, ruleset_t*); rsRetVal MsgSetFlowControlType(msg_t *pMsg, flowControl_t eFlowCtl); diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index ea78e823..4f813f95 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -30,6 +30,7 @@ * # Config Settings # * * ############################################################# */ #define RS_STRINGBUF_ALLOC_INCREMENT 128 +#define CONF_TAG_MAXSIZE 512 /* a value that is deemed far too large for any valid TAG */ /* ############################################################# * * # End Config Settings # * |