1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-05 12:22:11 +03:00

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 8a11d04b77)
This commit is contained in:
Christopher R. Hertel
1998-08-21 19:57:59 +00:00
parent 7fe3a42857
commit c8b2ee3e4e

View File

@ -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... */