The following issues were found

src/mongo/db/catalog/rename_collection.cpp
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 780 Column: 18 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

                      str::stream() << "indexes of target collection " << targetNs.ns()
                      << " changed during processing.",
        originalIndexes.size() == currentIndexes.size() &&
            std::equal(originalIndexes.begin(),
                       originalIndexes.end(),
                       currentIndexes.begin(),
                       [&](auto& lhs, auto& rhs) { return comparator.compare(lhs, rhs) == 0; }));

    validateAndRunRenameCollection(opCtx, sourceNs, targetNs, options);

            

Reported by FlawFinder.

src/mongo/db/catalog/rename_collection_test.cpp
1 issues
syntax error
Error

Line: 514

                  return CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, nss);
}

TEST_F(RenameCollectionTest, RenameCollectionReturnsNamespaceNotFoundIfDatabaseDoesNotExist) {
    ASSERT_FALSE(AutoGetDb(_opCtx.get(), _sourceNss.db(), MODE_X).getDb());
    ASSERT_EQUALS(ErrorCodes::NamespaceNotFound,
                  renameCollection(_opCtx.get(), _sourceNss, _targetNss, {}));
}


            

Reported by Cppcheck.

src/mongo/db/catalog/throttle_cursor_test.cpp
1 issues
syntax error
Error

Line: 118

                  return SortedDataInterfaceThrottleCursor(operationContext(), iam, _dataThrottle.get());
}

TEST_F(ThrottleCursorTest, TestSeekableRecordThrottleCursorOff) {
    auto opCtx = operationContext();
    AutoGetCollection autoColl(opCtx, kNss, MODE_X);
    const CollectionPtr& coll = autoColl.getCollection();

    // Use a fixed record data size to simplify the timing calculations.

            

Reported by Cppcheck.

src/mongo/db/catalog/util/partitioned_test.cpp
1 issues
syntax error
Error

Line: 44

              const std::size_t nPartitions = 3;
using PartitionedIntSet = Partitioned<std::set<std::size_t>, nPartitions>;

TEST(Partitioned, DefaultConstructedPartitionedShouldBeEmpty) {
    PartitionedIntSet test;
    ASSERT_TRUE(test.empty());
}

TEST(Partitioned, InsertionShouldModifySize) {

            

Reported by Cppcheck.

src/mongo/db/catalog/validate_state_test.cpp
1 issues
syntax error
Error

Line: 152

              }

// ValidateState constructor should throw if the collection doesn't exist.
TEST_F(ValidateStateTest, NonExistentCollectionShouldThrowNamespaceNotFoundError) {
    auto opCtx = operationContext();

    ASSERT_THROWS_CODE(
        CollectionValidation::ValidateState(opCtx,
                                            kNss,

            

Reported by Cppcheck.

src/mongo/db/catalog_raii_test.cpp
1 issues
syntax error
Error

Line: 88

                  }
}

TEST_F(CatalogRAIITestFixture, AutoGetDBDeadline) {
    Lock::DBLock dbLock1(client1.second.get(), nss.db(), MODE_X);
    ASSERT(client1.second->lockState()->isDbLockedForMode(nss.db(), MODE_X));
    failsWithLockTimeout(
        [&] { AutoGetDb db(client2.second.get(), nss.db(), MODE_X, Date_t::now() + timeoutMs); },
        timeoutMs);

            

Reported by Cppcheck.

src/mongo/db/client_context_test.cpp
1 issues
syntax error
Error

Line: 48

                  constexpr static auto kClientName2 = "bar";
};

TEST_F(ClientTest, UuidsAreDifferent) {
    // This test trivially asserts that the uuid for two Client instances are different. This is not
    // intended to test the efficacy of our uuid generation. Instead, this is to make sure that we
    // are not default constructing or reusing the same UUID for all Client instances.
    auto client1 = getServiceContext()->makeClient(kClientName1);
    auto client2 = getServiceContext()->makeClient(kClientName2);

            

Reported by Cppcheck.

src/mongo/db/client_out_of_line_executor_test.cpp
1 issues
syntax error
Error

Line: 100

                  AtomicWord<int> _instanceCount;
};

TEST_F(ClientOutOfLineExecutorTest, CheckDecoration) {
    auto decoration = getDecoration();
    ASSERT(decoration);
}

TEST_F(ClientOutOfLineExecutorTest, ScheduleAndExecute) {

            

Reported by Cppcheck.

src/mongo/db/client_strand_test.cpp
1 issues
syntax error
Error

Line: 88

                  }
};

TEST_F(ClientStrandTest, CreateOnly) {
    auto strand = ClientStrand::make(getServiceContext()->makeClient(kClientName1));

    // We have no bound Client.
    assertStrandNotBound(strand);


            

Reported by Cppcheck.

src/mongo/db/collection_index_usage_tracker_test.cpp
1 issues
syntax error
Error

Line: 64

              };

// Test that a newly contructed tracker has an empty map.
TEST_F(CollectionIndexUsageTrackerTest, Empty) {
    ASSERT(getTracker()->getUsageStats()->empty());
}

// Test that recording of a single index hit is reflected in returned stats map.
TEST_F(CollectionIndexUsageTrackerTest, SingleHit) {

            

Reported by Cppcheck.