The following issues were found
src/mongo/util/secure_zero_memory_test.cpp
1 issues
Line: 45
ASSERT_TRUE(true);
}
DEATH_TEST(SecureZeroMemoryTest, zeroNonzeroLengthNull, "Fatal assertion") {
void* ptr = nullptr;
secureZeroMemory(ptr, 1000);
}
TEST(SecureZeroMemoryTest, dataZeroed) {
Reported by Cppcheck.
src/mongo/util/shared_buffer_fragment.h
1 issues
Line: 150
Column: 17
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
// building.
auto newBuffer = SharedBuffer::allocate(allocSize);
if (_buffer)
memcpy(newBuffer.get(), _buffer.get() + _offset, currentCapacity);
_buffer = std::move(newBuffer);
_offset = 0;
}
}
Reported by FlawFinder.
src/mongo/util/signal_handlers_synchronous.cpp
1 issues
Line: 140
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
private:
static const size_t maxLogLineSize = 100 * 1000;
char _buffer[maxLogLineSize];
};
class MallocFreeOStream : public std::ostream {
MallocFreeOStream(const MallocFreeOStream&) = delete;
MallocFreeOStream& operator=(const MallocFreeOStream&) = delete;
Reported by FlawFinder.
src/mongo/util/signal_handlers_synchronous_test.cpp
1 issues
Line: 58
ASSERT_EQ(0, raise(SIGNUM)); \
}
IGNORED_SIGNAL(SIGUSR2)
IGNORED_SIGNAL(SIGHUP)
IGNORED_SIGNAL(SIGPIPE)
FATAL_SIGNAL(SIGQUIT)
FATAL_SIGNAL(SIGILL)
FATAL_SIGNAL(SIGABRT)
Reported by Cppcheck.
src/mongo/util/stacktrace_posix.cpp
1 issues
Line: 348
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
unw_context_t _context;
unw_cursor_t _cursor;
char _symbolBuf[kSymbolMax];
};
#endif // MONGO_STACKTRACE_BACKEND
class RawBacktraceIteration : public IterationIface {
public:
Reported by FlawFinder.
src/mongo/util/static_immortal_test.cpp
1 issues
Line: 57
void useConst() const {}
};
TEST(StaticImmortalTest, BasicConstructorAndCast) {
ctors = 0;
{
auto&& x = *StaticImmortal<Indestructible>();
x.use();
}
Reported by Cppcheck.
src/mongo/util/str.cpp
1 issues
Line: 239
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
}
std::string convertDoubleToString(double d, int prec) {
char buffer[StringBuilder::MONGO_DBL_SIZE];
int z = snprintf(buffer, sizeof(buffer), "%.*g", prec, d);
invariant(z >= 0);
return std::string(buffer);
}
Reported by FlawFinder.
src/mongo/util/str_test.cpp
1 issues
Line: 44
using namespace fmt::literals;
using std::string;
TEST(StringUtilsTest, Basic) {
//
// Basic version comparison tests with different version string types
//
// Equal
Reported by Cppcheck.
src/mongo/util/strong_weak_finish_line_test.cpp
1 issues
Line: 57
ASSERT_FALSE(finishLine.arriveWeakly());
}
TEST(StrongWeakFinishLineTest, AllWeakArrival) {
StrongWeakFinishLine finishLine(3);
ASSERT_FALSE(finishLine.isReady());
ASSERT_FALSE(finishLine.arriveWeakly());
Reported by Cppcheck.
src/mongo/util/summation_test.cpp
1 issues
Line: 103
} // namespace
TEST(Summation, AddLongs) {
int iter = 0;
for (auto x : longValues) {
for (auto y : longValues) {
for (auto z : longValues) {
iter++;
Reported by Cppcheck.