The following issues were found
src/mongo/db/storage/storage_repair_observer_test.cpp
1 issues
Line: 132
bool _assertRepairIncompleteOnTearDown = false;
};
TEST_F(StorageRepairObserverTest, DataUnmodified) {
auto repairObserver = getRepairObserver();
auto repairFile = repairFilePath();
ASSERT(!boost::filesystem::exists(repairFile));
ASSERT(!repairObserver->isIncomplete());
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_index_test.cpp
1 issues
Line: 53
using std::string;
TEST(WiredTigerIndexTest, GenerateCreateStringEmptyDocument) {
BSONObj spec = fromjson("{}");
StatusWith<std::string> result = WiredTigerIndex::parseIndexOptions(spec);
ASSERT_OK(result.getStatus());
ASSERT_EQ(result.getValue(), ""); // "," would also be valid.
}
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_init_test.cpp
1 issues
Line: 95
}
// Do not validate fields that are not present in metadata.
TEST_F(WiredTigerFactoryTest, ValidateMetadataEmptyOptions) {
_testValidateMetadata(factory, BSONObj(), false, false, ErrorCodes::OK);
_testValidateMetadata(factory, BSONObj(), false, true, ErrorCodes::OK);
_testValidateMetadata(factory, BSONObj(), true, false, ErrorCodes::OK);
_testValidateMetadata(factory, BSONObj(), false, false, ErrorCodes::OK);
}
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
1 issues
Line: 127
WiredTigerKVEngineRepairTest() : WiredTigerKVEngineTest(true /* repair */) {}
};
TEST_F(WiredTigerKVEngineRepairTest, OrphanedDataFilesCanBeRecovered) {
auto opCtxPtr = _makeOperationContext();
NamespaceString nss("a.b");
std::string ident = "collection-1234";
std::string record = "abcd";
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
1 issues
Line: 62
using std::stringstream;
using std::unique_ptr;
TEST(WiredTigerRecordStoreTest, GenerateCreateStringEmptyDocument) {
BSONObj spec = fromjson("{}");
StatusWith<std::string> result = WiredTigerRecordStore::parseOptionsField(spec);
ASSERT_OK(result.getStatus());
ASSERT_EQ(result.getValue(), ""); // "," would also be valid.
}
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
1 issues
Line: 754
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
}
Timestamp WiredTigerRecoveryUnit::_getTransactionReadTimestamp(WT_SESSION* session) {
char buf[(2 * 8 /*bytes in hex*/) + 1 /*nul terminator*/];
auto wtstatus = session->query_timestamp(session, buf, "get=read");
invariantWTOK(wtstatus);
uint64_t read_timestamp;
fassert(50949, NumberParser().base(16)(buf, &read_timestamp));
return Timestamp(read_timestamp);
Reported by FlawFinder.
src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
1 issues
Line: 174
const char* wt_config = "key_format=S,value_format=S";
};
TEST_F(WiredTigerRecoveryUnitTestFixture, SetReadSource) {
// Storage engine operations require at least Global IS.
Lock::GlobalLock lk(clientAndCtx1.second.get(), MODE_IS);
ru1->setTimestampReadSource(RecoveryUnit::ReadSource::kProvided, Timestamp(1, 1));
ASSERT_EQ(RecoveryUnit::ReadSource::kProvided, ru1->getTimestampReadSource());
ASSERT_EQ(Timestamp(1, 1), ru1->getPointInTimeReadTimestamp(clientAndCtx1.second.get()));
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_session_cache_test.cpp
1 issues
Line: 93
WiredTigerSessionCache _sessionCache;
};
TEST(WiredTigerSessionCacheTest, CheckSessionCacheCleanup) {
WiredTigerSessionCacheHarnessHelper harnessHelper("");
WiredTigerSessionCache* sessionCache = harnessHelper.getSessionCache();
ASSERT_EQUALS(sessionCache->getIdleSessionsCount(), 0U);
{
UniqueWiredTigerSession _session = sessionCache->getSession();
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
1 issues
Line: 157
mongo::registerSortedDataInterfaceHarnessHelperFactory(makeWTIndexHarnessHelper);
}
TEST(WiredTigerStandardIndexText, CursorInActiveTxnAfterNext) {
auto harnessHelper = makeWTIndexHarnessHelper();
bool unique = false;
bool partial = false;
auto sdi = harnessHelper->newSortedDataInterface(unique, partial);
Reported by Cppcheck.
src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
1 issues
Line: 67
ASSERT_THROWS(rs->storageSize(opCtx.get()), AssertionException);
}
TEST(WiredTigerRecordStoreTest, SizeStorer1) {
unique_ptr<WiredTigerHarnessHelper> harnessHelper(new WiredTigerHarnessHelper());
unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());
string ident = rs->getIdent();
string uri = checked_cast<WiredTigerRecordStore*>(rs.get())->getURI();
Reported by Cppcheck.