The following issues were found

src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp
1 issues
syntax error
Error

Line: 80

              // Insert a KeyString and verify that dupKeyCheck() returns a non-OK status for
// the same KeyString. When dupKeyCheck() is called with the exact KeyString
// pair that was inserted, it should still return an OK status.
TEST(SortedDataInterface, DupKeyCheckAfterInsertKeyString) {
    const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
    const std::unique_ptr<SortedDataInterface> sorted(
        harnessHelper->newSortedDataInterface(/*unique=*/true, /*partial=*/false));

    auto keyString1 = makeKeyString(sorted.get(), key1, loc1);

            

Reported by Cppcheck.

src/mongo/db/storage/sorted_data_interface_test_harness.cpp
1 issues
syntax error
Error

Line: 145

                  }
}

TEST(SortedDataInterface, InsertWithDups2) {
    const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
    const std::unique_ptr<SortedDataInterface> sorted(
        harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));

    {

            

Reported by Cppcheck.

src/mongo/db/storage/sorted_data_interface_test_insert.cpp
1 issues
syntax error
Error

Line: 73

              }

// Insert a KeyString and verify that the number of entries in the index equals 1.
TEST(SortedDataInterface, InsertKeyString) {
    const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
    const std::unique_ptr<SortedDataInterface> sorted(
        harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));

    auto keyString1 = makeKeyString(sorted.get(), key1, loc1);

            

Reported by Cppcheck.

src/mongo/db/storage/sorted_data_interface_test_rollback.cpp
1 issues
syntax error
Error

Line: 85

              // Insert multiple keys, then unindex those same keys and verify that
// omitting the commit() on the WriteUnitOfWork causes the changes to
// not become visible.
TEST(SortedDataInterface, UnindexWithoutCommit) {
    const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
    const std::unique_ptr<SortedDataInterface> sorted(
        harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));

    {

            

Reported by Cppcheck.

src/mongo/db/storage/sorted_data_interface_test_spaceused.cpp
1 issues
syntax error
Error

Line: 53

              }

// Verify that a nonempty index takes up some space.
TEST(SortedDataInterface, GetSpaceUsedBytesNonEmpty) {
    const auto harnessHelper(newSortedDataInterfaceHarnessHelper());
    const std::unique_ptr<SortedDataInterface> sorted(
        harnessHelper->newSortedDataInterface(/*unique=*/false, /*partial=*/false));

    {

            

Reported by Cppcheck.

src/mongo/db/storage/sorted_data_interface_test_unindex.cpp
1 issues
syntax error
Error

Line: 81

                  }
}

TEST(SortedDataInterface, Unindex) {
    unindex(false);
}

TEST(SortedDataInterface, UnindexPartial) {
    unindex(true);

            

Reported by Cppcheck.

src/mongo/db/storage/storage_engine_init.cpp
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: 247 Column: 39 CWE codes: 362

                              false);
    }
    const bool wasUnclean = lockFile->createdByUncleanShutdown();
    const auto openStatus = lockFile->open();
    if (storageGlobalParams.readOnly && openStatus == ErrorCodes::IllegalOperation) {
        lockFile = boost::none;
    } else {
        uassertStatusOK(openStatus);
    }

            

Reported by FlawFinder.

src/mongo/db/storage/storage_engine_lock_file.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: 75 Column: 12 CWE codes: 362

                  /**
     * Opens and locks 'mongod.lock' in 'dbpath' directory.
     */
    Status open();

    /**
     * Closes lock file handles.
     */
    void close();

            

Reported by FlawFinder.

src/mongo/db/storage/storage_engine_lock_file_windows.cpp
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: 102 Column: 31 CWE codes: 362

                  return _uncleanShutdown;
}

Status StorageEngineLockFile::open() {
    try {
        if (!boost::filesystem::exists(_dbpath)) {
            return Status(ErrorCodes::NonExistentPath, _getNonExistentPathMessage());
        }
    } catch (const std::exception& ex) {

            

Reported by FlawFinder.

src/mongo/db/storage/storage_engine_metadata.h
1 issues
read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 101 Column: 12 CWE codes: 120 20

                  /**
     * Reads metadata from 'storage.bson' in 'dbpath' directory.
     */
    Status read();

    /**
     * Writes metadata to file.
     */
    Status write() const;

            

Reported by FlawFinder.