The following issues were found
src/mongo/util/lockable_adapter_test.cpp
1 issues
Line: 76
} // namespace
TEST(BasicLockableAdapter, TestWithConditionVariable) {
bool ready = false;
stdx::condition_variable_any cv;
stdx::mutex mut; // NOLINT
auto result = stdx::async(stdx::launch::async, [&ready, &mut, &cv] {
Reported by Cppcheck.
src/mongo/util/log_with_sampling_test.cpp
1 issues
Line: 72
opCtx.get(), component, Milliseconds{slowOp ? 11 : 9}, Milliseconds{10});
}
TEST(LogWithSamplingTest, SlowOpWithoutDebugLogging) {
{
auto [logSlow, sample] = scenario(false, true, true);
ASSERT_TRUE(logSlow) << "should log when sampled";
ASSERT_TRUE(sample) << "should sample when sampled";
}
Reported by Cppcheck.
src/mongo/util/lru_cache_test.cpp
1 issues
Line: 155
}
// Test that using cfind() returns the element without promoting it.
TEST(LRUCacheTest, CFindTest) {
runWithDifferentSizes([](int maxSize) {
LRUCache<int, int> cache(maxSize);
// Fill up the cache
for (int i = 0; i < maxSize; i++) {
Reported by Cppcheck.
src/mongo/util/net/cidr.cpp
1 issues
Line: 82
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
template <class T>
T& append(T& s, int family, const std::array<uint8_t, 16> ip, int len) {
char buffer[INET6_ADDRSTRLEN + 1] = {};
if (inet_ntop(family, ip.data(), buffer, sizeof(buffer) - 1)) {
s << buffer << '/' << (int)len;
}
return s;
}
Reported by FlawFinder.
src/mongo/util/net/cidr_test.cpp
1 issues
Line: 62
}
}
TEST(CIDRTest, contains) {
struct {
std::string range;
std::string value;
bool should_match;
} test_data[] = {
Reported by Cppcheck.
src/mongo/util/net/hostandport_test.cpp
1 issues
Line: 55
ASSERT_FALSE(HostAndPort("a", 2) < HostAndPort("a", 1));
}
TEST(HostAndPort, BasicEquality) {
// Comparison on host field
ASSERT_EQUALS(HostAndPort("a", 1), HostAndPort("a", 1));
ASSERT_FALSE(HostAndPort("b", 1) == HostAndPort("a", 1));
ASSERT_FALSE(HostAndPort("a", 1) != HostAndPort("a", 1));
ASSERT_NOT_EQUALS(HostAndPort("b", 1), HostAndPort("a", 1));
Reported by Cppcheck.
src/mongo/util/net/hostname_canonicalization.cpp
1 issues
Line: 117
Column: 13
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
results.emplace_back(shim_fromNativeString(host));
} else {
// Format the addrinfo structure we have into a string for reporting
char ip_str[INET6_ADDRSTRLEN];
struct sockaddr* addr = p->ai_addr;
void* sin_addr = nullptr;
if (p->ai_family == AF_INET) {
struct sockaddr_in* addr_in = reinterpret_cast<struct sockaddr_in*>(addr);
Reported by FlawFinder.
src/mongo/util/net/http_client_curl.cpp
1 issues
Line: 174
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (cdrc->length() > 0) {
size_t readSize = std::min(size * nitems, cdrc->length());
memcpy(buffer, cdrc->data(), readSize);
invariant(cdrc->advanceNoThrow(readSize).isOK());
ret = readSize;
}
return ret;
Reported by FlawFinder.
src/mongo/util/net/network_interface_ssl_test.cpp
1 issues
Line: 91
}
};
TEST_F(NetworkInterfaceSSLFixture, Ping) {
assertCommandOK(
"admin", BSON("ping" << 1), RemoteCommandRequest::kNoTimeout, transport::kEnableSSL);
}
} // namespace
Reported by Cppcheck.
src/mongo/util/net/openssl_init.cpp
1 issues
Line: 170
SSL_load_error_strings();
ERR_load_crypto_strings();
if (sslGlobalParams.sslFIPSMode) {
setupFIPS();
}
// Add all digests and ciphers to OpenSSL's internal table
// so that encryption/decryption is backwards compatible
Reported by Cppcheck.