The following issues were found
src/third_party/boost/libs/filesystem/src/path_traits.cpp
5 issues
Line: 23
Column: 23
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
namespace pt = boost::filesystem::path_traits;
namespace fs = boost::filesystem;
namespace bs = boost::system;
//--------------------------------------------------------------------------------------//
// configuration //
//--------------------------------------------------------------------------------------//
Reported by FlawFinder.
Line: 150
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
}
else
{
wchar_t buf[default_codecvt_buf_size];
convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
}
}
//--------------------------------------------------------------------------------------//
Reported by FlawFinder.
Line: 189
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
}
else
{
char buf[default_codecvt_buf_size];
convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
}
}
}}} // namespace boost::filesystem::path_traits
Reported by FlawFinder.
Line: 135
Column: 30
CWE codes:
126
if (!from_end) // null terminated
{
from_end = from + std::strlen(from);
}
if (from == from_end) return;
std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK
Reported by FlawFinder.
Line: 169
Column: 30
CWE codes:
126
if (!from_end) // null terminated
{
from_end = from + std::wcslen(from);
}
if (from == from_end) return;
// The codecvt length functions may not be implemented, and I don't really
Reported by FlawFinder.
src/mongo/util/generate_icu_init_cpp.py
5 issues
Line: 30
Column: 1
# exception statement from all source files in the program, then also delete
# it in the license file.
import optparse
import os
import sys
def main(argv):
Reported by Pylint.
Line: 31
Column: 1
# it in the license file.
import optparse
import os
import sys
def main(argv):
parser = optparse.OptionParser()
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
#
# Copyright (C) 2018-present MongoDB, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Server Side Public License, version 1,
# as published by MongoDB, Inc.
#
# This program is distributed in the hope that it will be useful,
Reported by Pylint.
Line: 35
Column: 1
import sys
def main(argv):
parser = optparse.OptionParser()
parser.add_option('-o', '--output', action='store', dest='output_cpp_file',
help='path to output cpp file')
parser.add_option('-i', '--input', action='store', dest='input_data_file',
help='input ICU data file, in common format (.dat)')
Reported by Pylint.
Line: 51
Column: 1
generate_cpp_file(options.input_data_file, options.output_cpp_file)
def generate_cpp_file(data_file_path, cpp_file_path):
source_template = '''// AUTO-GENERATED FILE DO NOT EDIT
// See generate_icu_init_cpp.py.
/**
* Copyright (C) 2018-present MongoDB, Inc.
*
Reported by Pylint.
src/mongo/db/exec/document_value/document.cpp
5 issues
Line: 205
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
// Append structure of a ValueElement
char* dest = _cache + pos.index; // must be after alloc since it changes _cache
#define append(x) \
memcpy(dest, &(x), sizeof(x)); \
dest += sizeof(x)
append(value);
append(nextCollision);
append(nameSize);
append(kind);
Reported by FlawFinder.
Line: 267
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (!firstAlloc) {
// This just copies the elements
memcpy(_cache, oldBuf.get(), _usedBytes);
if (_numFields >= HASH_TAB_MIN) {
// if we were hashing, deal with the hash table
if (doingRehash) {
rehash();
Reported by FlawFinder.
Line: 275
Column: 17
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
rehash();
} else {
// no rehash needed so just slide table down to new position
memcpy(_hashTab, oldBuf.get() + oldCapacity, hashTabBytes());
}
}
}
}
Reported by FlawFinder.
Line: 308
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
const size_t bufferBytes = allocatedBytes();
out->_cache = new char[bufferBytes];
out->_cacheEnd = out->_cache + (_cacheEnd - _cache);
memcpy(out->_cache, _cache, bufferBytes);
out->_hashTabMask = _hashTabMask;
out->_usedBytes = _usedBytes;
out->_numFields = _numFields;
Reported by FlawFinder.
Line: 792
Column: 30
CWE codes:
120
20
}
Document Document::deserializeForSorter(BufReader& buf, const SorterDeserializeSettings&) {
const int numElems = buf.read<LittleEndian<int>>();
MutableDocument doc(numElems);
for (int i = 0; i < numElems; i++) {
StringData name = buf.readCStr();
doc.addField(name, Value::deserializeForSorter(buf, Value::SorterDeserializeSettings()));
}
Reported by FlawFinder.
src/third_party/wiredtiger/examples/c/ex_config_parse.c
5 issues
Line: 50
Column: 62
CWE codes:
126
"path=/dev/loop,page_size=1024,log=(archive=true,file_max=20MB)";
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
error_check(parser->close(parser));
/*! [Create a configuration parser] */
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
Reported by FlawFinder.
Line: 55
Column: 62
CWE codes:
126
/*! [Create a configuration parser] */
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
{
/*! [get] */
int64_t my_page_size;
/*
Reported by FlawFinder.
Line: 73
Column: 66
CWE codes:
126
{
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
/*! [next] */
/*
* Retrieve and print the values of the configuration strings.
*/
while ((ret = parser->next(parser, &k, &v)) == 0) {
Reported by FlawFinder.
Line: 91
Column: 62
CWE codes:
126
}
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
/*! [nested get] */
/*
* Retrieve the value of the nested log file_max configuration string using dot shorthand.
* Utilize the configuration parsing automatic conversion of value strings into an integer.
Reported by FlawFinder.
Line: 105
Column: 62
CWE codes:
126
error_check(parser->close(parser));
error_check(
wiredtiger_config_parser_open(NULL, config_string, strlen(config_string), &parser));
/*! [nested traverse] */
{
WT_CONFIG_PARSER *sub_parser;
while ((ret = parser->next(parser, &k, &v)) == 0) {
if (v.type == WT_CONFIG_ITEM_STRUCT) {
Reported by FlawFinder.
src/third_party/boost/boost/type_traits/type_with_alignment.hpp
5 issues
Line: 134
Column: 4
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 tt_align_ns {
struct __declspec(align(8)) a8 {
char m[8];
typedef a8 type;
};
struct __declspec(align(16)) a16 {
char m[16];
typedef a16 type;
Reported by FlawFinder.
Line: 138
Column: 4
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
typedef a8 type;
};
struct __declspec(align(16)) a16 {
char m[16];
typedef a16 type;
};
struct __declspec(align(32)) a32 {
char m[32];
typedef a32 type;
Reported by FlawFinder.
Line: 142
Column: 4
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
typedef a16 type;
};
struct __declspec(align(32)) a32 {
char m[32];
typedef a32 type;
};
struct __declspec(align(64)) a64
{
char m[64];
Reported by FlawFinder.
Line: 147
Column: 4
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 __declspec(align(64)) a64
{
char m[64];
typedef a64 type;
};
struct __declspec(align(128)) a128 {
char m[128];
typedef a128 type;
Reported by FlawFinder.
Line: 151
Column: 4
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
typedef a64 type;
};
struct __declspec(align(128)) a128 {
char m[128];
typedef a128 type;
};
}
template<> struct type_with_alignment<8>
Reported by FlawFinder.
src/mongo/util/future_test_edge_cases.cpp
5 issues
Line: 165
// This is the motivating case for SharedStateBase::isJustForContinuation. Without that logic, there
// would be a long chain of SharedStates, growing longer with each recursion. That logic exists to
// limit it to a fixed-size chain.
TEST(Future_EdgeCases, looping_onError) {
int tries = 10;
std::function<Future<int>()> read = [&] {
return async([&] {
uassert(ErrorCodes::BadValue, "", --tries == 0);
return tries;
Reported by Cppcheck.
Line: 172
Column: 43
CWE codes:
120
20
uassert(ErrorCodes::BadValue, "", --tries == 0);
return tries;
})
.onError([&](Status) { return read(); });
};
ASSERT_EQ(read().get(), 0);
}
// This tests for a bug in an earlier implementation of isJustForContinuation. Due to an off-by-one,
Reported by FlawFinder.
Line: 174
Column: 15
CWE codes:
120
20
})
.onError([&](Status) { return read(); });
};
ASSERT_EQ(read().get(), 0);
}
// This tests for a bug in an earlier implementation of isJustForContinuation. Due to an off-by-one,
// it would replace the "then" continuation's SharedState. A different type is used for the return
// from then to cause it to fail a checked_cast close to the bug in debug builds.
Reported by FlawFinder.
Line: 187
Column: 43
CWE codes:
120
20
uassert(ErrorCodes::BadValue, "", --tries == 0);
return tries;
})
.onError([&](Status) { return read(); });
};
ASSERT_EQ(read().then([](int x) { return x + 0.5; }).get(), 0.5);
}
TEST(Future_EdgeCases, interrupted_wait_then_get) {
Reported by FlawFinder.
Line: 189
Column: 15
CWE codes:
120
20
})
.onError([&](Status) { return read(); });
};
ASSERT_EQ(read().then([](int x) { return x + 0.5; }).get(), 0.5);
}
TEST(Future_EdgeCases, interrupted_wait_then_get) {
DummyInterruptible dummyInterruptible;
Reported by FlawFinder.
src/mongo/util/file.cpp
5 issues
Line: 113
Column: 12
CWE codes:
362
return 0;
}
void File::open(const char* filename, bool readOnly, bool direct) {
_name = filename;
_handle = CreateFileW(toNativeString(filename).c_str(), // filename
(readOnly ? 0 : GENERIC_WRITE) | GENERIC_READ, // desired access
FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode
nullptr, // security
Reported by FlawFinder.
Line: 282
Column: 12
CWE codes:
362
#define O_NOATIME 0
#endif
void File::open(const char* filename, bool readOnly, bool direct) {
_name = filename;
_fd = ::open(filename,
(readOnly ? O_RDONLY : (O_CREAT | O_RDWR | O_NOATIME))
#if defined(O_DIRECT)
| (direct ? O_DIRECT : 0)
Reported by FlawFinder.
Line: 284
Column: 13
CWE codes:
362
void File::open(const char* filename, bool readOnly, bool direct) {
_name = filename;
_fd = ::open(filename,
(readOnly ? O_RDONLY : (O_CREAT | O_RDWR | O_NOATIME))
#if defined(O_DIRECT)
| (direct ? O_DIRECT : 0)
#endif
,
Reported by FlawFinder.
Line: 133
Column: 12
CWE codes:
120
20
}
}
void File::read(fileofs o, char* data, unsigned len) {
LARGE_INTEGER li;
li.QuadPart = o;
if (SetFilePointerEx(_handle, li, nullptr, FILE_BEGIN) == 0) {
_bad = true;
DWORD dosError = GetLastError();
Reported by FlawFinder.
Line: 301
Column: 12
CWE codes:
120
20
}
}
void File::read(fileofs o, char* data, unsigned len) {
ssize_t bytesRead = ::pread(_fd, data, len, o);
if (bytesRead == -1) {
_bad = true;
LOGV2(23154,
"In File::read(), ::pread for '{fileName}' failed with {error}",
Reported by FlawFinder.
src/third_party/wiredtiger/dist/test_data.py
5 issues
Line: 1
Column: 1
# This file is a python script that describes the cpp test framework test configuration options.
class Method:
def __init__(self, config):
# Deal with duplicates: with complex configurations (like
# WT_SESSION::create), it's simpler to deal with duplicates once than
# manually as configurations are defined
self.config = []
lastname = None
Reported by Pylint.
Line: 3
Column: 1
# This file is a python script that describes the cpp test framework test configuration options.
class Method:
def __init__(self, config):
# Deal with duplicates: with complex configurations (like
# WT_SESSION::create), it's simpler to deal with duplicates once than
# manually as configurations are defined
self.config = []
lastname = None
Reported by Pylint.
Line: 3
Column: 1
# This file is a python script that describes the cpp test framework test configuration options.
class Method:
def __init__(self, config):
# Deal with duplicates: with complex configurations (like
# WT_SESSION::create), it's simpler to deal with duplicates once than
# manually as configurations are defined
self.config = []
lastname = None
Reported by Pylint.
Line: 10
Column: 13
# manually as configurations are defined
self.config = []
lastname = None
for c in sorted(config):
if '.' in c.name:
raise "Bad config key '%s'" % c.name
if c.name == lastname:
continue
lastname = c.name
Reported by Pylint.
Line: 18
Column: 1
lastname = c.name
self.config.append(c)
class Config:
def __init__(self, name, default, desc, subconfig=None, **flags):
self.name = name
self.default = default
self.desc = desc
self.subconfig = subconfig
Reported by Pylint.
src/mongo/util/fail_point_test.cpp
5 issues
Line: 73
MONGO_FAIL_POINT_DEFINE(dummy2);
} // namespace
TEST(FailPoint, InitialState) {
FailPoint failPoint("testFP");
ASSERT_FALSE(failPoint.shouldFail());
}
TEST(FailPoint, AlwaysOn) {
Reported by Cppcheck.
Line: 300
Column: 58
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
}
TEST(FailPoint, RandomActivationP0) {
ASSERT_EQUALS(0, runParallelFailPointTest(FailPoint::random, 0, 1, 1000000));
}
TEST(FailPoint, RandomActivationP5) {
ASSERT_APPROX_EQUAL(500000,
runParallelFailPointTest(
Reported by FlawFinder.
Line: 306
Column: 40
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
TEST(FailPoint, RandomActivationP5) {
ASSERT_APPROX_EQUAL(500000,
runParallelFailPointTest(
FailPoint::random, std::numeric_limits<int32_t>::max() / 2, 10, 100000),
1000);
}
TEST(FailPoint, RandomActivationP01) {
ASSERT_APPROX_EQUAL(
Reported by FlawFinder.
Line: 314
Column: 24
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
ASSERT_APPROX_EQUAL(
10000,
runParallelFailPointTest(
FailPoint::random, std::numeric_limits<int32_t>::max() / 100, 10, 100000),
500);
}
TEST(FailPoint, RandomActivationP001) {
ASSERT_APPROX_EQUAL(
Reported by FlawFinder.
Line: 322
Column: 24
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
ASSERT_APPROX_EQUAL(
1000,
runParallelFailPointTest(
FailPoint::random, std::numeric_limits<int32_t>::max() / 1000, 10, 100000),
500);
}
TEST(FailPoint, parseBSONEmptyFails) {
auto swTuple = FailPoint::parseBSON(BSONObj());
Reported by FlawFinder.
src/third_party/boost/boost/regex/v5/regex_workaround.hpp
5 issues
Line: 122
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
if (lenSourceWithNull > sizeInBytes)
return 1;
std::memcpy(strDestination, strSource, lenSourceWithNull);
return 0;
}
inline std::size_t strcat_s(
char *strDestination,
std::size_t sizeInBytes,
Reported by FlawFinder.
Line: 135
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
std::size_t lenDestination = std::strlen(strDestination);
if (lenSourceWithNull + lenDestination > sizeInBytes)
return 1;
std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull);
return 0;
}
#endif
Reported by FlawFinder.
Line: 119
Column: 41
CWE codes:
126
const char *strSource
)
{
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
if (lenSourceWithNull > sizeInBytes)
return 1;
std::memcpy(strDestination, strSource, lenSourceWithNull);
return 0;
}
Reported by FlawFinder.
Line: 131
Column: 41
CWE codes:
126
const char *strSource
)
{
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
std::size_t lenDestination = std::strlen(strDestination);
if (lenSourceWithNull + lenDestination > sizeInBytes)
return 1;
std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull);
return 0;
Reported by FlawFinder.
Line: 132
Column: 38
CWE codes:
126
)
{
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
std::size_t lenDestination = std::strlen(strDestination);
if (lenSourceWithNull + lenDestination > sizeInBytes)
return 1;
std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull);
return 0;
}
Reported by FlawFinder.