Details
Description
The code that logs the beginning and end of lines longer than 10 KB inserts two NULs into the log.
At lines 339 and 342 in src/mongo/util/log.cpp in Logstream::flush(), the calls to b.appendStr() should include a 'false' second argument to prevent the addition of unwanted NUL characters.
This code:
if ( msg.size() > MAX_LOG_LINE ) {
|
stringstream sss;
|
sss << "warning: log line attempted (" << msg.size() / 1024 << "k) over max size(" << MAX_LOG_LINE / 1024 << "k)";
|
sss << ", printing beginning and end ... ";
|
b.appendStr( sss.str() );
|
const char * xx = msg.c_str();
|
b.appendBuf( xx , MAX_LOG_LINE / 3 );
|
b.appendStr( " .......... " );
|
b.appendStr( xx + msg.size() - ( MAX_LOG_LINE / 3 ) );
|
}
|
else {
|
b.appendStr( msg );
|
}
|
should be
if ( msg.size() > MAX_LOG_LINE ) {
|
stringstream sss;
|
sss << "warning: log line attempted (" << msg.size() / 1024 << "k) over max size(" << MAX_LOG_LINE / 1024 << "k)";
|
sss << ", printing beginning and end ... ";
|
b.appendStr( sss.str(), false );
|
const char * xx = msg.c_str();
|
b.appendBuf( xx , MAX_LOG_LINE / 3 );
|
b.appendStr( " .......... ", false );
|
b.appendStr( xx + msg.size() - ( MAX_LOG_LINE / 3 ) );
|
}
|
else {
|
b.appendStr( msg );
|
}
|