The following issues were found
src/leveldb/db/write_batch_test.cc
1 issues
Line: 57
class WriteBatchTest {};
TEST(WriteBatchTest, Empty) {
WriteBatch batch;
ASSERT_EQ("", PrintContents(&batch));
ASSERT_EQ(0, WriteBatchInternal::Count(&batch));
}
Reported by Cppcheck.
src/leveldb/db/version_set_test.cc
1 issues
Line: 53
std::vector<FileMetaData*> files_;
};
TEST(FindFileTest, Empty) {
ASSERT_EQ(0, Find("foo"));
ASSERT_TRUE(!Overlaps("a", "z"));
ASSERT_TRUE(!Overlaps(nullptr, "z"));
ASSERT_TRUE(!Overlaps("a", nullptr));
ASSERT_TRUE(!Overlaps(nullptr, nullptr));
Reported by Cppcheck.
src/leveldb/db/version_set.h
1 issues
Line: 268
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
// Return a human-readable short (single-line) summary of the number
// of files per level. Uses *scratch as backing store.
struct LevelSummaryStorage {
char buffer[100];
};
const char* LevelSummary(LevelSummaryStorage* scratch) const;
private:
class Builder;
Reported by FlawFinder.
src/test/serialize_tests.cpp
1 issues
Line: 23
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
int intval;
bool boolval;
std::string stringval;
char charstrval[16];
CTransactionRef txval;
public:
CSerializeMethodsTestSingle() = default;
CSerializeMethodsTestSingle(int intvalin, bool boolvalin, std::string stringvalin, const uint8_t* charstrvalin, const CTransactionRef& txvalin) : intval(intvalin), boolval(boolvalin), stringval(std::move(stringvalin)), txval(txvalin)
{
Reported by FlawFinder.
src/test/serfloat_tests.cpp
1 issues
Line: 93
Column: 17
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
v &= ~(uint64_t{1} << 63);
if (x & 256) v |= (uint64_t{1} << 63);
double f;
memcpy(&f, &v, 8);
uint64_t v2 = TestDouble(f);
if (!std::isnan(f)) BOOST_CHECK_EQUAL(v, v2);
}
}
}
Reported by FlawFinder.
src/test/scriptnum_tests.cpp
1 issues
Line: 13
#include <limits.h>
#include <stdint.h>
BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup)
/** A selection of numbers that do not trigger int64_t overflow
* when added/subtracted. */
static const int64_t values[] = { 0, 1, -2, 127, 128, -255, 256, (1LL << 15) - 1, -(1LL << 16), (1LL << 24) - 1, (1LL << 31), 1 - (1LL << 32), 1LL << 40 };
Reported by Cppcheck.
src/leveldb/db/version_set.cc
1 issues
Line: 208
Column: 11
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
uint32_t index_;
// Backing store for value(). Holds the file number and size.
mutable char value_buf_[16];
};
static Iterator* GetFileIterator(void* arg, const ReadOptions& options,
const Slice& file_value) {
TableCache* cache = reinterpret_cast<TableCache*>(arg);
Reported by FlawFinder.
src/leveldb/db/version_edit_test.cc
1 issues
Line: 22
class VersionEditTest {};
TEST(VersionEditTest, EncodeDecode) {
static const uint64_t kBig = 1ull << 50;
VersionEdit edit;
for (int i = 0; i < 4; i++) {
TestEncodeDecode(edit);
Reported by Cppcheck.
src/test/scheduler_tests.cpp
1 issues
Line: 16
#include <thread>
#include <vector>
BOOST_AUTO_TEST_SUITE(scheduler_tests)
static void microTask(CScheduler& s, std::mutex& mutex, int& counter, int delta, std::chrono::system_clock::time_point rescheduleTime)
{
{
std::lock_guard<std::mutex> lock(mutex);
Reported by Cppcheck.
src/leveldb/db/skiplist_test.cc
1 issues
Line: 36
class SkipTest {};
TEST(SkipTest, Empty) {
Arena arena;
Comparator cmp;
SkipList<Key, Comparator> list(cmp, &arena);
ASSERT_TRUE(!list.Contains(10));
Reported by Cppcheck.