From c8b2ee3e4e85c6afc43ea72643e5609f23f49ae7 Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Fri, 21 Aug 1998 19:57:59 +0000 Subject: 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) --- source3/lib/debug.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source3') 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 @@ -21,6 +21,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. * @@ -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... */ -- cgit