summaryrefslogtreecommitdiff
path: root/template.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2010-11-30 15:09:49 +0100
committerMichael Biebl <biebl@debian.org>2010-11-30 15:09:49 +0100
commit0a5a3fba01d42ef3b380c4ae27699bb42c3af493 (patch)
treecba36f6ed3cf72059d16e4e702be01325c1f73c7 /template.c
parent7e2b1add5ffd1d726801b5f3806c7e26f493c3e9 (diff)
downloadrsyslog-0a5a3fba01d42ef3b380c4ae27699bb42c3af493.tar.gz
Imported Upstream version 5.7.2upstream/5.7.2
Diffstat (limited to 'template.c')
-rw-r--r--template.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/template.c b/template.c
index c46d144..06949e4 100644
--- a/template.c
+++ b/template.c
@@ -85,7 +85,7 @@ rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar **ppBuf, size_t *
{
DEFiRet;
struct templateEntry *pTpe;
- int iBuf;
+ size_t iBuf;
unsigned short bMustBeFreed;
uchar *pVal;
size_t iLenVal;
@@ -141,7 +141,15 @@ rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar **ppBuf, size_t *
pTpe = pTpe->pNext;
}
- (*ppBuf)[iBuf] = '\0'; /* space was reserved above (see copy) */
+ if(iBuf == *pLenBuf) {
+ /* in the weired case of an *empty* template, this can happen.
+ * it is debatable if we should really fix it here or simply
+ * forbid that case. However, performance toll is minimal, so
+ * I tend to permit it. -- 201011-05 rgerhards
+ */
+ CHKiRet(ExtendBuf(ppBuf, pLenBuf, iBuf + 1));
+ }
+ (*ppBuf)[iBuf] = '\0';
finalize_it:
RETiRet;