Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7036

long log lines are logged with added NULs when truncated

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.2, 2.3.0
    • Component/s: Logging
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL

      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 );
      }

        Attachments

          Activity

            People

            Assignee:
            tad Tad Marshall
            Reporter:
            tad Tad Marshall
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: