The following issues were found
src/third_party/abseil-cpp-master/abseil-cpp/absl/synchronization/internal/graphcycles_test.cc
2 issues
Line: 191
return i == edges->size()? -1 : i;
}
TEST(GraphCycles, RandomizedTest) {
int next_node = 0;
Nodes nodes;
Edges edges; // from, to
IdMap id;
GraphCycles graph_cycles;
Reported by Cppcheck.
Line: 398
Column: 7
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
break;
}
if (!result.empty()) result.push_back(' ');
char buf[20];
snprintf(buf, sizeof(buf), "%d", Num(g_.Ptr(path[i])));
result += buf;
}
return result;
}
Reported by FlawFinder.
src/third_party/abseil-cpp-master/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc
2 issues
Line: 151
PerThreadSemTest::TestTiming("Without timeout: ", false);
}
TEST_F(PerThreadSemTest, WithTimeout) {
PerThreadSemTest::TestTiming("With timeout: ", true);
}
TEST_F(PerThreadSemTest, Timeouts) {
const absl::Duration delay = absl::Milliseconds(50);
Reported by Cppcheck.
Line: 119
Column: 23
CWE codes:
120
min_cycles = std::min(min_cycles, cycles);
total_cycles += cycles;
}
std::string out = StrCat(
msg, "min cycle count=", min_cycles, " avg cycle count=",
absl::SixDigits(static_cast<double>(total_cycles) / kNumIterations));
printf("%s\n", out.c_str());
partner_thread.join();
Reported by FlawFinder.
src/third_party/abseil-cpp-master/abseil-cpp/absl/synchronization/internal/waiter.h
2 issues
Line: 141
Column: 27
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
// We can't include Windows.h in our headers, so we use aligned charachter
// buffers to define the storage of SRWLOCK and CONDITION_VARIABLE.
alignas(void*) unsigned char mu_storage_[sizeof(void*)];
alignas(void*) unsigned char cv_storage_[sizeof(void*)];
int waiter_count_;
int wakeup_count_;
#else
Reported by FlawFinder.
Line: 142
Column: 27
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
// We can't include Windows.h in our headers, so we use aligned charachter
// buffers to define the storage of SRWLOCK and CONDITION_VARIABLE.
alignas(void*) unsigned char mu_storage_[sizeof(void*)];
alignas(void*) unsigned char cv_storage_[sizeof(void*)];
int waiter_count_;
int wakeup_count_;
#else
#error Unknown ABSL_WAITER_MODE
Reported by FlawFinder.
src/mongo/util/procparser.cpp
2 issues
Line: 92
Column: 14
CWE codes:
362
* be reading directly from the kernel.
*/
StatusWith<std::string> readFileAsString(StringData filename) {
int fd = open(filename.toString().c_str(), 0);
if (fd == -1) {
int err = errno;
return Status(ErrorCodes::FileOpenFailed,
str::stream() << "Failed to open file " << filename
<< " with error: " << errnoWithDescription(err));
Reported by FlawFinder.
Line: 113
Column: 25
CWE codes:
120
20
size_t retry = 0;
do {
size_read = read(fd, buf.data(), kFileBufferSize);
if (size_read == -1) {
int err = errno;
// Retry if we hit EGAIN or EINTR a few times before giving up
Reported by FlawFinder.
src/mongo/db/index/2d_key_generator_test.cpp
2 issues
Line: 99
SharedBufferFragmentBuilder allocator{KeyString::HeapBuilder::kHeapAllocatorDefaultBytes};
};
TEST_F(TwoDKeyGeneratorTest, TrailingField) {
BSONObj obj = fromjson("{a: [0, 0], b: 5}");
BSONObj infoObj = fromjson("{key: {a: '2d', b: 1}}");
TwoDIndexingParams params;
ExpressionParams::parseTwoDParams(infoObj, ¶ms);
KeyStringSet actualKeys;
Reported by Cppcheck.
Line: 71
Column: 15
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
return false;
}
if (!std::equal(expectedKeys.begin(), expectedKeys.end(), actualKeys.begin())) {
LOGV2(20646,
"Expected: {dumpKeyset_expectedKeys}, Actual: {dumpKeyset_actualKeys}",
"dumpKeyset_expectedKeys"_attr = dumpKeyset(expectedKeys),
"dumpKeyset_actualKeys"_attr = dumpKeyset(actualKeys));
return false;
Reported by FlawFinder.
src/mongo/db/hasher.cpp
2 issues
Line: 46
Column: 18
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
namespace {
typedef unsigned char HashDigest[16];
class Hasher {
Hasher(const Hasher&) = delete;
Hasher& operator=(const Hasher&) = delete;
Reported by FlawFinder.
Line: 148
Column: 23
CWE codes:
120
20
h.finish(d);
// HashDigest is actually 16 bytes, but we just read 8 bytes
ConstDataView digestView(reinterpret_cast<const char*>(d));
return digestView.read<LittleEndian<long long int>>();
}
} // namespace mongo
Reported by FlawFinder.
src/third_party/boost/boost/algorithm/string/detail/classification.hpp
2 issues
Line: 131
Column: 28
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
// Use fixed storage
::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
}
// Destructor
~is_any_ofF()
{
Reported by FlawFinder.
Line: 211
Column: 28
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
// Copy the data
::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
return *this;
}
// Operation
Reported by FlawFinder.
src/mongo/db/exec/sbe/stages/unwind.cpp
2 issues
Line: 89
Column: 19
CWE codes:
362
return _children[0]->getAccessor(ctx, slot);
}
void UnwindStage::open(bool reOpen) {
auto optTimer(getOptTimer(_opCtx));
_commonStats.opens++;
_children[0]->open(reOpen);
Reported by FlawFinder.
Line: 93
Column: 19
CWE codes:
362
auto optTimer(getOptTimer(_opCtx));
_commonStats.opens++;
_children[0]->open(reOpen);
_index = 0;
_inArray = false;
}
Reported by FlawFinder.
src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
2 issues
Line: 803
CWE codes:
587
}
void setEndPosition(const BSONObj& key, bool inclusive) override {
LOGV2_TRACE_CURSOR(20098,
"setEndPosition inclusive: {inclusive} {key}",
"inclusive"_attr = inclusive,
"key"_attr = key);
if (key.isEmpty()) {
// This means scan to end of index.
Reported by Cppcheck.
Line: 925
CWE codes:
587
// Unique indexes can have both kinds of KeyStrings, ie with or without the record id.
// Restore for unique indexes gets handled separately in it's own implementation.
_lastMoveSkippedKey = !seekWTCursor(_key.getValueCopy());
LOGV2_TRACE_CURSOR(20099,
"restore _lastMoveSkippedKey: {lastMoveSkippedKey}",
"lastMoveSkippedKey"_attr = _lastMoveSkippedKey);
}
}
Reported by Cppcheck.
src/third_party/abseil-cpp-master/abseil-cpp/absl/time/duration.cc
2 issues
Line: 727
Column: 3
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
0.0}; // prec ignored
void AppendNumberUnit(std::string* out, int64_t n, DisplayUnit unit) {
char buf[sizeof("2562047788015216")]; // hours in max duration
char* const ep = buf + sizeof(buf);
char* bp = Format64(ep, 0, n);
if (*bp != '0' || bp + 1 != ep) {
out->append(bp, ep - bp);
out->append(unit.abbr.data(), unit.abbr.size());
Reported by FlawFinder.
Line: 741
Column: 3
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
void AppendNumberUnit(std::string* out, double n, DisplayUnit unit) {
constexpr int kBufferSize = std::numeric_limits<double>::digits10;
const int prec = std::min(kBufferSize, unit.prec);
char buf[kBufferSize]; // also large enough to hold integer part
char* ep = buf + sizeof(buf);
double d = 0;
int64_t frac_part = Round(std::modf(n, &d) * unit.pow10);
int64_t int_part = d;
if (int_part != 0 || frac_part != 0) {
Reported by FlawFinder.