summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>1998-08-21 19:57:59 +0000
committerChristopher R. Hertel <crh@samba.org>1998-08-21 19:57:59 +0000
commitc8b2ee3e4e85c6afc43ea72643e5609f23f49ae7 (patch)
tree78aaf2cfa5843c018c9d7d5241e150fef0e55b0e /source3
parent7fe3a42857792a70bdd729fefa2311b77ae86e7e (diff)
downloadsamba-c8b2ee3e4e85c6afc43ea72643e5609f23f49ae7.tar.gz
samba-c8b2ee3e4e85c6afc43ea72643e5609f23f49ae7.tar.bz2
samba-c8b2ee3e4e85c6afc43ea72643e5609f23f49ae7.zip
Just tweaking.
If the output line is longer than the format buffer could manage, I was simply ignoring the additional output (that is, *not* copying it to the format buffer--thus avoiding a buffer overrun). Instead, I now output the current content followed by " +>\n", and then reset the format buffer. I have never seen a debug line that exceeds the size of a pstring, but I might as well handle the situation...just in case. Chris -)----- (This used to be commit 8a11d04b7796b256953bf92b2f2ccab763215bc4)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/debug.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 1303d0433b..6469a3ca6c 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -22,6 +22,16 @@
#include "includes.h"
/* -------------------------------------------------------------------------- **
+ * Defines...
+ *
+ * FORMAT_BUFR_MAX - Index of the last byte of the format buffer;
+ * format_bufr[FORMAT_BUFR_MAX] should always be reserved
+ * for a terminating nul byte.
+ */
+
+#define FORMAT_BUFR_MAX ( sizeof( format_bufr ) - 1 )
+
+/* -------------------------------------------------------------------------- **
* This module implements Samba's debugging utility.
*
* The syntax of a debugging log file is represented as:
@@ -416,7 +426,6 @@ static void bufr_print( void )
*/
static void format_debug_text( char *msg )
{
- int max = sizeof( format_bufr ) - 1;
int i;
for( i = 0; msg[i]; i++ )
@@ -429,12 +438,21 @@ static void format_debug_text( char *msg )
}
/* If there's room, copy the character to the format buffer. */
- if( format_pos < max )
+ if( format_pos < FORMAT_BUFR_MAX )
format_bufr[format_pos++] = msg[i];
/* If a newline is encountered, print & restart. */
if( '\n' == msg[i] )
bufr_print();
+
+ /* If the buffer is full dump it out, reset it, and put out a line
+ * continuation indicator.
+ */
+ if( format_pos >= FORMAT_BUFR_MAX )
+ {
+ bufr_print();
+ (void)Debug1( " +>\n" );
+ }
}
/* Just to be safe... */