summaryrefslogtreecommitdiffstats
path: root/source/lib/debug.c
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
commit8a11d04b7796b256953bf92b2f2ccab763215bc4 (patch)
tree1c6140cc06684407ccdea76b5025ede6d4ec2b20 /source/lib/debug.c
parentb1d374fb14b1fb92a84260f1dcc59a39a4b99a3d (diff)
downloadsamba-8a11d04b7796b256953bf92b2f2ccab763215bc4.tar.gz
samba-8a11d04b7796b256953bf92b2f2ccab763215bc4.tar.xz
samba-8a11d04b7796b256953bf92b2f2ccab763215bc4.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 -)-----
Diffstat (limited to 'source/lib/debug.c')
-rw-r--r--source/lib/debug.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source/lib/debug.c b/source/lib/debug.c
index 1303d0433b7..6469a3ca6ca 100644
--- a/source/lib/debug.c
+++ b/source/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... */