diff options
author | Miloslav Trmač <mitr@redhat.com> | 2012-09-25 13:52:41 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-10-11 18:11:47 +0200 |
commit | 5552202b01fd4f472d23aa50db6614ec2fe9c68e (patch) | |
tree | 217f9ad60ae9c5c321f8ba66458ed380da625d1a /runtime/msg.c | |
parent | 2ae9e456db8991e61b4aa48cf9b74f6d20689ce4 (diff) | |
download | rsyslog-5552202b01fd4f472d23aa50db6614ec2fe9c68e.tar.gz rsyslog-5552202b01fd4f472d23aa50db6614ec2fe9c68e.tar.bz2 rsyslog-5552202b01fd4f472d23aa50db6614ec2fe9c68e.zip |
Fix crash when date properties are used without a template
E.g. in
> set $!time = $timereported;
> set $!time_rcvd = $timegenerated;
pTpe is set to NULL by the caller.
(Is "default" the correct format to use?)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index d3c814e2..d874178b 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2698,6 +2698,7 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, uchar *pBuf; int iLen; short iOffs; + enum tplFormatTypes datefmt; BEGINfunc assert(pMsg != NULL); @@ -2717,7 +2718,11 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, bufLen = getMSGLen(pMsg); break; case PROP_TIMESTAMP: - pRes = (uchar*)getTimeReported(pMsg, pTpe->data.field.eDateFormat); + if (pTpe != NULL) + datefmt = pTpe->data.field.eDateFormat; + else + datefmt = tplFmtDefault; + pRes = (uchar*)getTimeReported(pMsg, datefmt); break; case PROP_HOSTNAME: pRes = (uchar*)getHOSTNAME(pMsg); @@ -2767,7 +2772,11 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, pRes = (uchar*)getSeverityStr(pMsg); break; case PROP_TIMEGENERATED: - pRes = (uchar*)getTimeGenerated(pMsg, pTpe->data.field.eDateFormat); + if (pTpe != NULL) + datefmt = pTpe->data.field.eDateFormat; + else + datefmt = tplFmtDefault; + pRes = (uchar*)getTimeGenerated(pMsg, datefmt); break; case PROP_PROGRAMNAME: pRes = getProgramName(pMsg, LOCK_MUTEX); |