The following issues were found

src/mongo/util/net/ssl_options_server.cpp
1 issues
Syntax Error: AST broken, 'if' doesn't have two operands.
Error

Line: 93

              MONGO_STARTUP_OPTIONS_POST(SSLServerOptions)(InitializerContext*) {
    auto& params = moe::startupOptionsParsed;

    if (params.count("net.tls.mode")) {
        std::string sslModeParam = params["net.tls.mode"].as<string>();
        auto swMode = SSLParams::tlsModeParse(sslModeParam);
        if (swMode.isOK()) {
            sslGlobalParams.sslMode.store(swMode.getValue());
        } else {

            

Reported by Cppcheck.

src/mongo/util/net/ssl_options_test.cpp
1 issues
syntax error
Error

Line: 101

              }
}  // namespace test

TEST(SSLOptions, validCases) {
    SSLParams::CertificateSelector selector;

    ASSERT_OK(parseCertificateSelector(&selector, "subj", "subject=test.example.com"));
    ASSERT_EQ(selector.subject, "test.example.com");


            

Reported by Cppcheck.

src/mongo/util/ntservice_test.cpp
1 issues
Iterators of different containers are used together.
Error

Line: 112 CWE codes: 664

                  ASSERT_TRUE(NULL != inputArgvWide);
    ASSERT_GREATER_THAN_OR_EQUALS(inputArgc, 0);
    std::vector<std::string> inputArgvUtf8(inputArgc);
    ASSERT_TRUE(inputArgvUtf8.end() ==
                std::transform(
                    inputArgvWide, inputArgvWide + inputArgc, inputArgvUtf8.begin(), toUtf8String));
    LocalFree(inputArgvWide);

    // Finally, confirm that we properly transform the argument vector and from it construct a legit

            

Reported by Cppcheck.

src/mongo/util/options_parser/environment_test.cpp
1 issues
syntax error
Error

Line: 43

              
namespace moe = mongo::optionenvironment;

TEST(Environment, EmptyValue) {
    moe::Environment environment;
    ASSERT_NOT_OK(environment.set(moe::Key("empty"), moe::Value()));
}

TEST(Environment, MutuallyExclusive) {

            

Reported by Cppcheck.

src/mongo/util/options_parser/options_parser_init.cpp
1 issues
Syntax Error: AST broken, 'if' doesn't have two operands.
Error

Line: 60

                                        ("EndStartupOptionValidation"),
                          ("BeginStartupOptionStorage"))
(InitializerContext*) {
    if (startupOptionsParsed.count("outputConfig")) {
        bool output = false;
        uassertStatusOK(startupOptionsParsed.get(Key("outputConfig"), &output));
        if (output) {
            std::cout << startupOptionsParsed.toYAML() << std::endl;
            quickExit(EXIT_CLEAN);

            

Reported by Cppcheck.

src/mongo/util/options_parser/value.cpp
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 162 Column: 13 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              bool Value::isEmpty() const {
    return _type == None;
}
bool Value::equal(const Value& otherVal) const {
    if (_type != otherVal._type) {
        return false;
    }
    switch (_type) {
        case StringVector:

            

Reported by FlawFinder.

src/mongo/util/options_parser/value.h
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 113 Column: 10 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                   *
     *  Two empty values are equal
     */
    bool equal(const Value&) const;

    /**
     *  Return the std::string representation of this Value.  This function is used only for
     *  debugging purposes and does not output data in an easily parseable format.
     */

            

Reported by FlawFinder.

src/mongo/util/out_of_line_executor_test.cpp
1 issues
syntax error
Error

Line: 54

                  }
}

TEST(ExecutorTest, InlineQueuedCountingExecutor) {
    // Verify that the executor accepts every time and keeps an accurate count.
    const auto execA = InlineQueuedCountingExecutor::make();
    const auto execB = InlineQueuedCountingExecutor::make();

    // Using prime numbers so there is no chance of multiple traps

            

Reported by Cppcheck.

src/mongo/util/perfctr_collect.h
1 issues
open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 240 Column: 12 CWE codes: 362

                  /**
     * Open the PDH Query.
     */
    Status open();

    /**
     * Add the specified counter group to the PDH Query.
     */
    Status addCountersGroup(StringData groupName, const std::vector<std::string>& paths);

            

Reported by FlawFinder.

src/mongo/util/perfctr_collect_test.cpp
1 issues
syntax error
Error

Line: 132

              size_t kDefaultCollectionCount = 2;

// Simple verification test
TEST(FTDCPerfCollector, TestSingleCounter) {

    PerfCounterCollection collection;
    // PERF_100NSEC_TIMER
    ASSERT_OK(collection.addCountersGroup("cpu", {"\\Processor(0)\\% Idle Time"}));


            

Reported by Cppcheck.