The following issues were found
src/mongo/db/op_msg_fuzzer_fixture.cpp
2 issues
Line: 154
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
int new_size = Size + sizeof(int);
auto sb = SharedBuffer::allocate(new_size);
memcpy(sb.get(), &new_size, sizeof(int));
memcpy(sb.get() + sizeof(int), Data, Size);
Message msg(std::move(sb));
try {
_serviceContext->getServiceEntryPoint()->handleRequest(opCtx.get(), msg).get();
Reported by FlawFinder.
Line: 155
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
int new_size = Size + sizeof(int);
auto sb = SharedBuffer::allocate(new_size);
memcpy(sb.get(), &new_size, sizeof(int));
memcpy(sb.get() + sizeof(int), Data, Size);
Message msg(std::move(sb));
try {
_serviceContext->getServiceEntryPoint()->handleRequest(opCtx.get(), msg).get();
} catch (const AssertionException&) {
Reported by FlawFinder.
src/third_party/asio-master/asio/include/asio/ip/detail/socket_option.hpp
2 issues
Line: 403
Column: 7
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
using namespace std; // For memcpy.
address_v6 ipv6_address = multicast_address.to_v6();
address_v6::bytes_type bytes = ipv6_address.to_bytes();
memcpy(ipv6_value_.ipv6mr_multiaddr.s6_addr, bytes.data(), 16);
ipv6_value_.ipv6mr_interface = ipv6_address.scope_id();
}
else
{
ipv4_value_.imr_multiaddr.s_addr =
Reported by FlawFinder.
Line: 438
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
{
using namespace std; // For memcpy.
address_v6::bytes_type bytes = multicast_address.to_bytes();
memcpy(ipv6_value_.ipv6mr_multiaddr.s6_addr, bytes.data(), 16);
if (network_interface)
ipv6_value_.ipv6mr_interface = network_interface;
else
ipv6_value_.ipv6mr_interface = multicast_address.scope_id();
}
Reported by FlawFinder.
buildscripts/aggregate_tracefiles.py
2 issues
Line: 8
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
The last argument is the tracefile to which the output will be written.
"""
import subprocess
import os
import sys
from optparse import OptionParser
Reported by Bandit.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
print(' '.join(args))
return subprocess.call(args)
def getfilesize(path):
"""Return file size of 'path'."""
if not os.path.isfile(path):
Reported by Bandit.
src/third_party/boost/boost/archive/wcslen.hpp
2 issues
Line: 36
Column: 20
CWE codes:
126
|| defined(__LIBCOMO__)
namespace std {
inline std::size_t wcslen(const wchar_t * ws)
{
const wchar_t * eows = ws;
while(* eows != 0)
++eows;
return eows - ws;
Reported by FlawFinder.
Line: 51
Column: 24
CWE codes:
126
#include <cwchar>
#endif
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::wcslen; }
#endif
#endif // wcslen
#endif //BOOST_NO_CWCHAR
Reported by FlawFinder.
src/mongo/db/s/balancer/cluster_statistics_impl.cpp
2 issues
Line: 97
Column: 68
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
using ShardStatistics = ClusterStatistics::ShardStatistics;
ClusterStatisticsImpl::ClusterStatisticsImpl(BalancerRandomSource& random) : _random(random) {}
ClusterStatisticsImpl::~ClusterStatisticsImpl() = default;
StatusWith<std::vector<ShardStatistics>> ClusterStatisticsImpl::getStats(OperationContext* opCtx) {
// Get a list of all the shards that are participating in this balance round along with any
Reported by FlawFinder.
Line: 97
Column: 86
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
using ShardStatistics = ClusterStatistics::ShardStatistics;
ClusterStatisticsImpl::ClusterStatisticsImpl(BalancerRandomSource& random) : _random(random) {}
ClusterStatisticsImpl::~ClusterStatisticsImpl() = default;
StatusWith<std::vector<ShardStatistics>> ClusterStatisticsImpl::getStats(OperationContext* opCtx) {
// Get a list of all the shards that are participating in this balance round along with any
Reported by FlawFinder.
src/mongo/db/exec/sbe/stages/scan.h
2 issues
Line: 115
Column: 10
CWE codes:
362
void prepare(CompileCtx& ctx) final;
value::SlotAccessor* getAccessor(CompileCtx& ctx, value::SlotId slot) final;
void open(bool reOpen) final;
PlanState getNext() final;
void close() final;
std::unique_ptr<PlanStageStats> getStats(bool includeDebugInfo) const final;
const SpecificStats* getSpecificStats() const final;
Reported by FlawFinder.
Line: 224
Column: 10
CWE codes:
362
void prepare(CompileCtx& ctx) final;
value::SlotAccessor* getAccessor(CompileCtx& ctx, value::SlotId slot) final;
void open(bool reOpen) final;
PlanState getNext() final;
void close() final;
std::unique_ptr<PlanStageStats> getStats(bool includeDebugInfo) const final;
const SpecificStats* getSpecificStats() const final;
Reported by FlawFinder.
src/third_party/boost/boost/asio/detail/old_win_sdk_compat.hpp
2 issues
Line: 53
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
struct sockaddr_storage_emulation
{
short ss_family;
char __ss_pad1[sockaddr_storage_pad1size];
__int64 __ss_align;
char __ss_pad2[sockaddr_storage_pad2size];
};
struct in6_addr_emulation
Reported by FlawFinder.
Line: 55
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
short ss_family;
char __ss_pad1[sockaddr_storage_pad1size];
__int64 __ss_align;
char __ss_pad2[sockaddr_storage_pad2size];
};
struct in6_addr_emulation
{
union
Reported by FlawFinder.
src/mongo/db/exec/sbe/stages/sort.cpp
2 issues
Line: 160
Column: 17
CWE codes:
362
_tracker = tracker;
}
void SortStage::open(bool reOpen) {
auto optTimer(getOptTimer(_opCtx));
invariant(_opCtx);
_commonStats.opens++;
_children[0]->open(reOpen);
Reported by FlawFinder.
Line: 165
Column: 19
CWE codes:
362
invariant(_opCtx);
_commonStats.opens++;
_children[0]->open(reOpen);
makeSorter();
while (_children[0]->getNext() == PlanState::ADVANCED) {
value::MaterializedRow keys{_inKeyAccessors.size()};
Reported by FlawFinder.
src/third_party/abseil-cpp-master/abseil-cpp/absl/strings/internal/str_format/extension.h
2 issues
Line: 103
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
raw_.Write(v);
return;
}
memcpy(pos_, v.data(), n);
pos_ += n;
}
size_t size() const { return size_; }
Reported by FlawFinder.
Line: 128
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
FormatRawSinkImpl raw_;
size_t size_ = 0;
char* pos_ = buf_;
char buf_[1024];
};
struct Flags {
bool basic : 1; // fastest conversion: no flags, width, or precision
bool left : 1; // "-"
Reported by FlawFinder.
src/mongo/db/index/s2_bucket_key_generator_test.cpp
2 issues
Line: 137
}
};
TEST_F(S2BucketKeyGeneratorTest, GetS2BucketKeys) {
BSONObj keyPattern = fromjson("{'data.geo': '2dsphere'}");
BSONObj genKeysFrom = fromjson(
"{data: {geo: {"
"'0': {type: 'Point', coordinates: [0, 0]},"
"'1': {type: 'Point', coordinates: [3, 3]}"
Reported by Cppcheck.
Line: 92
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(206941,
"Expected: {dumpKeyset_expectedKeys}, Actual: {dumpKeyset_actualKeys}",
"dumpKeyset_expectedKeys"_attr = dumpKeyset(expectedKeys),
"dumpKeyset_actualKeys"_attr = dumpKeyset(actualKeys));
return false;
Reported by FlawFinder.