diff options
author | Michael Biebl <biebl@debian.org> | 2013-04-10 12:24:34 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2013-04-10 12:24:34 +0200 |
commit | 79b9293acbb763ad949ed7878f138f424dfa85ac (patch) | |
tree | 141c5e0b64fdfbee653542e8a0a3f6d7e3c94671 /runtime/msg.c | |
parent | d7c2f609d30d5e4d2c69dd2dc7305bd8ec5736ec (diff) | |
download | rsyslog-79b9293acbb763ad949ed7878f138f424dfa85ac.tar.gz |
Imported Upstream version 7.3.10upstream/7.3.10
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index c302a05..a5c5281 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -3230,13 +3230,18 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, uchar *pSb; iFrom = pTpe->data.field.iFromPos; iTo = pTpe->data.field.iToPos; - /* need to zero-base to and from (they are 1-based!) */ - if(iFrom > 0) - --iFrom; - if(iTo > 0) - --iTo; if(bufLen == -1) bufLen = ustrlen(pRes); + if(pTpe->data.field.options.bFromPosEndRelative) { + iFrom = (bufLen < iFrom) ? 0 : bufLen - iFrom; + iTo = (bufLen < iTo)? 0 : bufLen - iTo; + } else { + /* need to zero-base to and from (they are 1-based!) */ + if(iFrom > 0) + --iFrom; + if(iTo > 0) + --iTo; + } if(iFrom == 0 && iTo >= bufLen) { /* in this case, the requested string is a superset of what we already have, * so there is no need to do any processing. This is a frequent case for size-limited |