summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-15 09:29:54 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-15 09:29:54 +0100
commita1127abbae67ac3a9c154b1914b15f1e16deca56 (patch)
treeb54c896fa3e4a879f819acd3506d4c225681a82d
parent4f97db43dfbf78f08509a71a0924347d900707b8 (diff)
downloadrsyslog-a1127abbae67ac3a9c154b1914b15f1e16deca56.tar.gz
rsyslog-a1127abbae67ac3a9c154b1914b15f1e16deca56.tar.xz
rsyslog-a1127abbae67ac3a9c154b1914b15f1e16deca56.zip
bugfix(minor): handling of extremely large strings in dbgprintf() fixed
Previously, it could lead to garbagge output and, in extreme cases, also to segfaults. Note: this was a problem only when debug output was actually enabled, so it caused no problem in production use.
-rw-r--r--ChangeLog4
-rw-r--r--runtime/debug.c9
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fe59dd9..4a57639e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,10 @@ Version 4.6.2 [v4-stable] (rgerhards), 2010-03-??
in proper retries.
- bugfix: $omfileFlushOnTXEnd was turned on when set to off and vice
versa due to an invalid check
+- bugfix(minor): handling of extremely large strings in dbgprintf() fixed
+ Previously, it could lead to garbagge output and, in extreme cases, also
+ to segfaults. Note: this was a problem only when debug output was
+ actually enabled, so it caused no problem in production use.
---------------------------------------------------------------------------
Version 4.6.1 [v4-stable] (rgerhards), 2010-03-04
- re-enabled old pipe output (using new module ompipe, built-in) after
diff --git a/runtime/debug.c b/runtime/debug.c
index 4504aaad..bc581a5d 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -961,6 +961,15 @@ dbgprintf(char *fmt, ...)
va_start(ap, fmt);
lenWriteBuf = vsnprintf(pszWriteBuf, sizeof(pszWriteBuf), fmt, ap);
va_end(ap);
+ if(lenWriteBuf >= sizeof(pszWriteBuf)) {
+ /* prevent buffer overrruns and garbagge display */
+ pszWriteBuf[sizeof(pszWriteBuf) - 5] = '.';
+ pszWriteBuf[sizeof(pszWriteBuf) - 4] = '.';
+ pszWriteBuf[sizeof(pszWriteBuf) - 3] = '.';
+ pszWriteBuf[sizeof(pszWriteBuf) - 2] = '\n';
+ pszWriteBuf[sizeof(pszWriteBuf) - 1] = '\0';
+ lenWriteBuf = sizeof(pszWriteBuf);
+ }
dbgprint(NULL, pszWriteBuf, lenWriteBuf);
}