The following issues were found

src/mongo/base/encoded_value_storage.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 82 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  }

private:
    char _data[sizeof(Layout)];
};

}  // namespace mongo

            

Reported by FlawFinder.

src/mongo/base/initializer_test.cpp
1 issues
syntax error
Error

Line: 170

                  std::vector<State> states = std::vector<State>(graph.size(), kUnset);
};

TEST_F(InitializerTest, SuccessfulInitializationAndDeinitialization) {
    Initializer initializer;
    constructDependencyGraph(initializer);

    initializer.executeInitializers({});
    for (size_t i = 0; i != states.size(); ++i)

            

Reported by Cppcheck.

src/mongo/base/owned_pointer_map_test.cpp
1 issues
syntax error
Error

Line: 68

              
std::vector<string> DestructionLogger::_destroyedNames;

TEST(OwnedPointerMapTest, OwnedPointerDestroyed) {
    DestructionLogger::destroyedNames().clear();
    {
        OwnedPointerMap<int, DestructionLogger> owned;
        owned.mutableMap().insert(make_pair(0, new DestructionLogger("foo")));
        // owned destroyed

            

Reported by Cppcheck.

src/mongo/base/owned_pointer_vector_test.cpp
1 issues
syntax error
Error

Line: 64

              
std::vector<string> DestructionLogger::_destroyedNames;

TEST(OwnedPointerVectorTest, OwnedPointerDestroyed) {
    DestructionLogger::destroyedNames().clear();
    {
        OwnedPointerVector<DestructionLogger> owned;
        owned.mutableVector().push_back(new DestructionLogger("foo"));
        // owned destroyed

            

Reported by Cppcheck.

src/mongo/base/parse_number_test.cpp
1 issues
syntax error
Error

Line: 127

                  }
}

TEST(NumberParser, ParseNegatives) {
    apply(TestParsingNegatives, allTypes);
}

PARSE_TEST(TestRejectingBadBases) {
    struct Spec {

            

Reported by Cppcheck.

src/mongo/base/secure_allocator_test.cpp
1 issues
syntax error
Error

Line: 53

                  ASSERT_EQUALS(3, (*vec)[2]);
}

TEST(SecureAllocator, SecureString) {
    SecureAllocatorDefaultDomain::SecureString str;

    str->resize(2000, 'x');
    ASSERT_EQUALS(0, str->compare(*SecureAllocatorDefaultDomain::SecureString(2000, 'x')));


            

Reported by Cppcheck.

src/mongo/base/status_test.cpp
1 issues
syntax error
Error

Line: 52

                  ASSERT_EQUALS(status.reason(), "error");
}

TEST(Basic, IsA) {
    ASSERT(!Status(ErrorCodes::BadValue, "").isA<ErrorCategory::Interruption>());
    ASSERT(Status(ErrorCodes::Interrupted, "").isA<ErrorCategory::Interruption>());
    ASSERT(!Status(ErrorCodes::Interrupted, "").isA<ErrorCategory::ShutdownError>());
}


            

Reported by Cppcheck.

src/mongo/base/status_with_test.cpp
1 issues
syntax error
Error

Line: 61

              }

/** Check uassertStatusOK with various reference types */
TEST(StatusWith, UassertStatusOKReferenceTypes) {
    auto sd = "barbaz"_sd;
    auto sw = StatusWith(sd);

    const StatusWith<StringData>& cref = sw;
    ASSERT_EQUALS(uassertStatusOK(cref), sd);

            

Reported by Cppcheck.

src/mongo/base/string_data_test.cpp
1 issues
syntax error
Error

Line: 47

              
using std::string;

TEST(Construction, Empty) {
    StringData strData;
    ASSERT_EQUALS(strData.size(), 0U);
    ASSERT_TRUE(strData.rawData() == nullptr);
}


            

Reported by Cppcheck.

src/mongo/base/system_error_test.cpp
1 issues
syntax error
Error

Line: 50

                         mongoErrorCategory());
}

TEST(SystemError, Conversions) {
    ASSERT(make_error_code(ErrorCodes::AlreadyInitialized) == ErrorCodes::AlreadyInitialized);
    ASSERT(std::error_code(ErrorCodes::AlreadyInitialized, mongoErrorCategory()) ==
           ErrorCodes::AlreadyInitialized);
    ASSERT(make_error_condition(ErrorCodes::AlreadyInitialized) == ErrorCodes::AlreadyInitialized);
    ASSERT(std::error_condition(ErrorCodes::AlreadyInitialized) == ErrorCodes::AlreadyInitialized);

            

Reported by Cppcheck.