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

Some argument parsing silently truncates at NUL bytes

    XMLWordPrintable

Details

    • Fully Compatible
    • ALL
    • Platforms 2017-07-10

    Description

      A few options in mongod_options.cpp (such as "replication.replSetName") call std::string.c_str() then passes the result to a function that takes a std::string. This appears to be unintentional, but has the impact of silently truncating the option at the first \0 byte. I don't think it is possible to pass embedded NUL bytes on the command line so it requires a config file. Example config file:

      replication:
        replSetName: "Oh No\0!"
      

      I see a few possible options:

      1. Remove the c_str() and start including the NUL byte. Maybe also add validation with allowed characters in replSet names.
      2. Error if there is a NUL byte.
      3. Decide this is intentional and add a comment explaining it. We should also look at arguments without a c_str() and decide if they should also truncate.
      4. Decide that no options in the config file should support NUL bytes and error in the main options parser logic.

      Attachments

        Activity

          People

            ted.tuckman@mongodb.com Ted Tuckman
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: