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

Do not use indirect pointer to call 'snprintf'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.0.7, 2.2.0
    • Fix Version/s: 2.2.2, 2.3.0
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL

      Description

      In src/mongo/bson/util/builder.h in lines 250 to 256, we create a static initializer used to call sprintf_s on Windows or snprintf on other platforms. This makes it possible to crash at startup if another static initializer tries to use this function pointer before this one has run. Since the order in which static initializers run is unspecified by the C++ standard, this should be coded differently.

      Since Windows has a '_snprintf' function that does what 'snprintf' does on other platforms, this code can be replaced by a macro.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: