The following issues were found
src/third_party/wiredtiger/examples/c/ex_all.c
16 issues
Line: 1102
Column: 21
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
error_check(cursor->get_key(cursor, &filename));
(void)snprintf(
buf, sizeof(buf), "cp /path/database/%s /path/database.backup/%s", filename, filename);
error_check(system(buf));
}
scan_end_check(ret == WT_NOTFOUND);
error_check(cursor->close(cursor));
/*! [backup]*/
Reported by FlawFinder.
Line: 887
Column: 9
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
{
/*! [query timestamp] */
char timestamp_buf[2 * sizeof(uint64_t) + 1];
/*! [transaction timestamp] */
error_check(session->timestamp_transaction(session, "commit_timestamp=2a"));
/*! [transaction timestamp] */
Reported by FlawFinder.
Line: 1065
Column: 9
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
{
/*! [Pack fields into a buffer] */
char buf[100];
error_check(wiredtiger_struct_pack(session, buf, sizeof(buf), "iSh", 42, "hello", -3));
/*! [Pack fields into a buffer] */
{
/*! [Unpack fields from a buffer] */
Reported by FlawFinder.
Line: 1083
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
static void
backup(WT_SESSION *session)
{
char buf[1024];
WT_CURSOR *dup_cursor;
/*! [backup]*/
WT_CURSOR *cursor;
const char *filename;
Reported by FlawFinder.
Line: 1197
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
/* this is outside the example snippet on purpose; don't encourage compiling in keys */
const char *secretkey = "abcdef";
/*! [Configure sodium extension] */
char conf[1024];
snprintf(conf, sizeof(conf),
"create,extensions=[/usr/local/lib/libwiredtiger_sodium.so],"
"encryption=(name=sodium,secretkey=%s)",
secretkey);
error_check(wiredtiger_open(home, NULL, conf, &conn));
Reported by FlawFinder.
Line: 198
Column: 22
CWE codes:
126
/*! [Set the cursor's raw value] */
WT_ITEM value; /* Set the cursor's raw value. */
value.data = "another value";
value.size = strlen("another value");
cursor->set_value(cursor, &value);
/*! [Set the cursor's raw value] */
error_check(cursor->insert(cursor));
}
Reported by FlawFinder.
Line: 237
Column: 17
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
{
/*! [Cursor equality] */
int equal;
error_check(cursor->equals(cursor, other, &equal));
if (equal) {
/* Cursors reference the same key */
}
/*! [Cursor equality] */
Reported by FlawFinder.
Line: 238
Column: 56
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
{
/*! [Cursor equality] */
int equal;
error_check(cursor->equals(cursor, other, &equal));
if (equal) {
/* Cursors reference the same key */
}
/*! [Cursor equality] */
}
Reported by FlawFinder.
Line: 239
Column: 17
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
/*! [Cursor equality] */
int equal;
error_check(cursor->equals(cursor, other, &equal));
if (equal) {
/* Cursors reference the same key */
}
/*! [Cursor equality] */
}
}
Reported by FlawFinder.
Line: 312
Column: 22
CWE codes:
126
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz";
value.size = strlen(value.data);
cursor->set_key(cursor, "some key");
cursor->set_value(cursor, &value);
error_check(cursor->insert(cursor));
}
Reported by FlawFinder.
src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/gs.py
16 issues
Line: 56
Column: 5
def generate(env):
"""Add Builders and construction variables for Ghostscript to an
Environment."""
global GhostscriptAction
# The following try-except block enables us to use the Tool
# in standalone mode (without the accompanying pdf.py),
# whenever we need an explicit call of gs via the Gs()
# Builder ...
try:
Reported by Pylint.
Line: 70
Column: 5
bld = env['BUILDERS']['PDF']
bld.add_action('.ps', GhostscriptAction)
except ImportError as e:
pass
gsbuilder = SCons.Builder.Builder(action = SCons.Action.Action('$GSCOM', '$GSCOMSTR'))
env['BUILDERS']['Gs'] = gsbuilder
Reported by Pylint.
Line: 34
Column: 1
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "src/engine/SCons/Tool/gs.py bee7caf9defd6e108fc2998a2520ddb36a967691 2019-12-17 02:07:09 bdeegan"
import SCons.Action
import SCons.Builder
import SCons.Platform
import SCons.Util
Reported by Pylint.
Line: 42
Column: 1
import SCons.Util
# Ghostscript goes by different names on different platforms...
platform = SCons.Platform.platform_default()
if platform == 'os2':
gs = 'gsos2'
elif platform == 'win32':
gs = 'gswin32c'
Reported by Pylint.
Line: 45
Column: 5
platform = SCons.Platform.platform_default()
if platform == 'os2':
gs = 'gsos2'
elif platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
Reported by Pylint.
Line: 47
Column: 5
if platform == 'os2':
gs = 'gsos2'
elif platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
GhostscriptAction = None
Reported by Pylint.
Line: 49
Column: 5
elif platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
GhostscriptAction = None
def generate(env):
"""Add Builders and construction variables for Ghostscript to an
Reported by Pylint.
Line: 51
Column: 1
else:
gs = 'gs'
GhostscriptAction = None
def generate(env):
"""Add Builders and construction variables for Ghostscript to an
Environment."""
global GhostscriptAction
Reported by Pylint.
Line: 56
Column: 5
def generate(env):
"""Add Builders and construction variables for Ghostscript to an
Environment."""
global GhostscriptAction
# The following try-except block enables us to use the Tool
# in standalone mode (without the accompanying pdf.py),
# whenever we need an explicit call of gs via the Gs()
# Builder ...
try:
Reported by Pylint.
Line: 64
Column: 1
try:
if GhostscriptAction is None:
GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR')
from SCons.Tool import pdf
pdf.generate(env)
bld = env['BUILDERS']['PDF']
bld.add_action('.ps', GhostscriptAction)
Reported by Pylint.
src/third_party/wiredtiger/test/3rdparty/testtools-0.9.34/testtools/runtest.py
16 issues
Line: 97
Column: 9
:return: The result object the test was run against.
"""
result.startTest(self.case)
self.result = result
try:
self._exceptions = []
self._run_core()
if self._exceptions:
# One or more caught exceptions, now trigger the test's
Reported by Pylint.
Line: 115
Column: 52
def _run_core(self):
"""Run the user supplied test code."""
if self.exception_caught == self._run_user(self.case._run_setup,
self.result):
# Don't run the test method if we failed getting here.
self._run_cleanups(self.result)
return
# Run everything from here on in. If any of the methods raise an
Reported by Pylint.
Line: 125
Column: 17
failed = False
try:
if self.exception_caught == self._run_user(
self.case._run_test_method, self.result):
failed = True
finally:
try:
if self.exception_caught == self._run_user(
self.case._run_teardown, self.result):
Reported by Pylint.
Line: 130
Column: 21
finally:
try:
if self.exception_caught == self._run_user(
self.case._run_teardown, self.result):
failed = True
finally:
try:
if self.exception_caught == self._run_user(
self._run_cleanups, self.result):
Reported by Pylint.
Line: 145
Column: 29
self.result.addSuccess(self.case,
details=self.case.getDetails())
def _run_cleanups(self, result):
"""Run the cleanups that have been added with addCleanup.
See the docstring for addCleanup for more information.
:return: None if all cleanups ran without error,
Reported by Pylint.
Line: 154
Column: 15
``exception_caught`` if there was an error.
"""
failing = False
while self.case._cleanups:
function, arguments, keywordArguments = self.case._cleanups.pop()
got_exception = self._run_user(
function, *arguments, **keywordArguments)
if got_exception == self.exception_caught:
failing = True
Reported by Pylint.
Line: 155
Column: 53
"""
failing = False
while self.case._cleanups:
function, arguments, keywordArguments = self.case._cleanups.pop()
got_exception = self._run_user(
function, *arguments, **keywordArguments)
if got_exception == self.exception_caught:
failing = True
if failing:
Reported by Pylint.
Line: 175
Column: 9
return fn(*args, **kwargs)
except KeyboardInterrupt:
raise
except:
return self._got_user_exception(sys.exc_info())
def _got_user_exception(self, exc_info, tb_label='traceback'):
"""Called when user code raises an exception.
Reported by Pylint.
Line: 199
Column: 24
self.case.onException(exc_info, tb_label=tb_label)
finally:
del exc_info
for exc_class, handler in self.handlers:
if isinstance(e, exc_class):
self._exceptions.append(e)
return self.exception_caught
raise e
Reported by Pylint.
Line: 22
Column: 1
"""
class RunTest(object):
"""An object to run a test.
RunTest objects are used to implement the internal logic involved in
running a test. TestCase.__init__ stores _RunTest as the class of RunTest
to execute. Passing the runTest= parameter to TestCase.__init__ allows a
Reported by Pylint.
src/third_party/wiredtiger/test/suite/test_hs11.py
16 issues
Line: 29
Column: 1
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
import wiredtiger, wttest
from wtscenario import make_scenarios
from wiredtiger import stat
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
Reported by Pylint.
Line: 31
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
from wiredtiger import stat
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
class test_hs11(wttest.WiredTigerTestCase):
conn_config = 'cache_size=50MB,statistics=(all)'
Reported by Pylint.
Line: 55
Column: 24
return str(i)
return i
def get_stat(self, stat):
stat_cursor = self.session.open_cursor('statistics:')
val = stat_cursor[stat][2]
stat_cursor.close()
return val
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
Reported by Pylint.
Line: 29
Column: 1
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
import wiredtiger, wttest
from wtscenario import make_scenarios
from wiredtiger import stat
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
Reported by Pylint.
Line: 31
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
from wiredtiger import stat
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
class test_hs11(wttest.WiredTigerTestCase):
conn_config = 'cache_size=50MB,statistics=(all)'
Reported by Pylint.
Line: 35
Column: 1
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
class test_hs11(wttest.WiredTigerTestCase):
conn_config = 'cache_size=50MB,statistics=(all)'
session_config = 'isolation=snapshot'
key_format_values = [
('column', dict(key_format='r')),
('integer-row', dict(key_format='i')),
Reported by Pylint.
Line: 35
Column: 1
# test_hs11.py
# Ensure that updates without timestamps clear the history store records.
class test_hs11(wttest.WiredTigerTestCase):
conn_config = 'cache_size=50MB,statistics=(all)'
session_config = 'isolation=snapshot'
key_format_values = [
('column', dict(key_format='r')),
('integer-row', dict(key_format='i')),
Reported by Pylint.
Line: 50
Column: 5
scenarios = make_scenarios(key_format_values, update_type_values)
nrows = 10000
def create_key(self, i):
if self.key_format == 'S':
return str(i)
return i
def get_stat(self, stat):
Reported by Pylint.
Line: 55
Column: 5
return str(i)
return i
def get_stat(self, stat):
stat_cursor = self.session.open_cursor('statistics:')
val = stat_cursor[stat][2]
stat_cursor.close()
return val
Reported by Pylint.
src/third_party/boost/boost/regex/v5/w32_regex_traits.hpp
16 issues
Line: 256
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
private:
regex_constants::syntax_type m_char_map[1u << CHAR_BIT];
char m_lower_map[1u << CHAR_BIT];
std::uint16_t m_type_map[1u << CHAR_BIT];
template <class U>
void init();
};
Reported by FlawFinder.
Line: 750
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
//
// fill in lower case map:
//
char char_map[1 << CHAR_BIT];
for (int ii = 0; ii < (1 << CHAR_BIT); ++ii)
char_map[ii] = static_cast<char>(ii);
#ifndef BOOST_NO_ANSI_APIS
int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(r != 0);
Reported by FlawFinder.
Line: 761
Column: 22
CWE codes:
120
BOOST_REGEX_ASSERT(code_page != 0);
WCHAR wide_char_map[1 << CHAR_BIT];
int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(conv_r != 0);
WCHAR wide_lower_map[1 << CHAR_BIT];
int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(r != 0);
Reported by FlawFinder.
Line: 805
Column: 13
CWE codes:
120
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
return true;
Reported by FlawFinder.
Line: 836
Column: 13
CWE codes:
120
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
return true;
Reported by FlawFinder.
Line: 866
Column: 13
CWE codes:
120
return result;
#else
LPWSTR wide_name = (LPWSTR)_alloca((name.size() + 1) * sizeof(WCHAR));
if (::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.size(), wide_name, name.size() + 1) == 0)
return cat_type();
cat_type result(::LoadLibraryW(wide_name), &free_module);
return result;
#endif
Reported by FlawFinder.
Line: 877
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
inline std::string w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def)
{
#ifndef BOOST_NO_ANSI_APIS
char buf[256];
if (0 == ::LoadStringA(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
Reported by FlawFinder.
Line: 910
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
#ifndef BOOST_NO_WREGEX
inline std::wstring w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def)
{
wchar_t buf[256];
if (0 == ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
Reported by FlawFinder.
Line: 952
Column: 13
CWE codes:
120
int src_len = static_cast<int>(p2 - p1);
LPWSTR wide_p1 = (LPWSTR)_alloca((src_len + 1) * 2);
if (::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0)
return std::string(p1, p2);
int bytes = ::LCMapStringW(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
Reported by FlawFinder.
Line: 1020
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
#endif
inline char w32_tolower(char c, lcid_type idx)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&c, // source string
Reported by FlawFinder.
src/third_party/wiredtiger/test/suite/test_assert01.py
16 issues
Line: 34
Column: 1
#
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_assert01(wttest.WiredTigerTestCase, suite_subprocess):
base = 'assert01'
base_uri = 'file:' + base
Reported by Pylint.
Line: 77
Column: 24
else:
msg = "/timestamp set on this transaction/"
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda:self.assertEquals(self.session.commit_transaction(),
0), msg)
c.close()
self.count += 1
# Commit without a timestamp
Reported by Pylint.
Line: 94
Column: 24
else:
msg = "/none set on this transaction/"
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda:self.assertEquals(self.session.commit_transaction(),
0), msg)
self.count += 1
c.close()
def test_commit_timestamp(self):
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
Reported by Pylint.
Line: 34
Column: 1
#
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_assert01(wttest.WiredTigerTestCase, suite_subprocess):
base = 'assert01'
base_uri = 'file:' + base
Reported by Pylint.
Line: 34
Column: 1
#
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_assert01(wttest.WiredTigerTestCase, suite_subprocess):
base = 'assert01'
base_uri = 'file:' + base
Reported by Pylint.
Line: 37
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_assert01(wttest.WiredTigerTestCase, suite_subprocess):
base = 'assert01'
base_uri = 'file:' + base
uri_always = base_uri + '.always.wt'
uri_def = base_uri + '.def.wt'
uri_never = base_uri + '.never.wt'
Reported by Pylint.
Line: 37
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_assert01(wttest.WiredTigerTestCase, suite_subprocess):
base = 'assert01'
base_uri = 'file:' + base
uri_always = base_uri + '.always.wt'
uri_def = base_uri + '.def.wt'
uri_never = base_uri + '.never.wt'
Reported by Pylint.
Line: 44
Column: 1
uri_def = base_uri + '.def.wt'
uri_never = base_uri + '.never.wt'
uri_none = base_uri + '.none.wt'
cfg_always = 'verbose=[write_timestamp],write_timestamp_usage=always,assert=(write_timestamp=on)'
cfg_def = ''
cfg_never = 'verbose=(write_timestamp=true),write_timestamp_usage=never,assert=(write_timestamp=on)'
cfg_none = 'assert=(write_timestamp=off)'
session_config = 'isolation=snapshot'
Reported by Pylint.
Line: 46
Column: 1
uri_none = base_uri + '.none.wt'
cfg_always = 'verbose=[write_timestamp],write_timestamp_usage=always,assert=(write_timestamp=on)'
cfg_def = ''
cfg_never = 'verbose=(write_timestamp=true),write_timestamp_usage=never,assert=(write_timestamp=on)'
cfg_none = 'assert=(write_timestamp=off)'
session_config = 'isolation=snapshot'
key_format_values = [
('column', dict(key_format='r', usestrings=False)),
Reported by Pylint.
src/third_party/wiredtiger/test/3rdparty/testtools-0.9.34/testtools/matchers/_doctest.py
16 issues
Line: 10
Column: 1
import doctest
import re
from ..compat import str_is_unicode
from ._impl import Mismatch
class _NonManglingOutputChecker(doctest.OutputChecker):
"""Doctest checker that works with unicode rather than mangling strings
Reported by Pylint.
Line: 11
Column: 1
import re
from ..compat import str_is_unicode
from ._impl import Mismatch
class _NonManglingOutputChecker(doctest.OutputChecker):
"""Doctest checker that works with unicode rather than mangling strings
Reported by Pylint.
Line: 43
Column: 20
if getattr(doctest, "_encoding", None) is not None:
from types import FunctionType as __F
__f = doctest.OutputChecker.output_difference.im_func
__g = dict(__f.func_globals)
def _indent(s, indent=4, _pattern=re.compile("^(?!$)", re.MULTILINE)):
"""Prepend non-empty lines in ``s`` with ``indent`` number of spaces"""
return _pattern.sub(indent*" ", s)
__g["_indent"] = _indent
output_difference = __F(__f.func_code, __g, "output_difference")
Reported by Pylint.
Line: 44
Column: 9
from types import FunctionType as __F
__f = doctest.OutputChecker.output_difference.im_func
__g = dict(__f.func_globals)
def _indent(s, indent=4, _pattern=re.compile("^(?!$)", re.MULTILINE)):
"""Prepend non-empty lines in ``s`` with ``indent`` number of spaces"""
return _pattern.sub(indent*" ", s)
__g["_indent"] = _indent
output_difference = __F(__f.func_code, __g, "output_difference")
del __F, __f, __g, _indent
Reported by Pylint.
Line: 48
Column: 33
"""Prepend non-empty lines in ``s`` with ``indent`` number of spaces"""
return _pattern.sub(indent*" ", s)
__g["_indent"] = _indent
output_difference = __F(__f.func_code, __g, "output_difference")
del __F, __f, __g, _indent
class DocTestMatches(object):
"""See if a string matches a doctest example."""
Reported by Pylint.
Line: 88
Column: 16
return DocTestMismatch(self, with_nl)
def _describe_difference(self, with_nl):
return self._checker.output_difference(self, with_nl, self.flags)
class DocTestMismatch(Mismatch):
"""Mismatch object for DocTestMatches."""
Reported by Pylint.
Line: 100
Column: 44
def describe(self):
s = self.matcher._describe_difference(self.with_nl)
if str_is_unicode or isinstance(s, unicode):
return s
# GZ 2011-08-24: This is actually pretty bogus, most C0 codes should
# be escaped, in addition to non-ascii bytes.
return s.decode("latin1").encode("ascii", "backslashreplace")
Reported by Pylint.
Line: 99
Column: 13
self.with_nl = with_nl
def describe(self):
s = self.matcher._describe_difference(self.with_nl)
if str_is_unicode or isinstance(s, unicode):
return s
# GZ 2011-08-24: This is actually pretty bogus, most C0 codes should
# be escaped, in addition to non-ascii bytes.
return s.decode("latin1").encode("ascii", "backslashreplace")
Reported by Pylint.
Line: 1
Column: 1
# Copyright (c) 2009-2012 testtools developers. See LICENSE for details.
__all__ = [
'DocTestMatches',
]
import doctest
import re
Reported by Pylint.
Line: 41
Column: 9
# Only do this overriding hackery if doctest has a broken _input function
if getattr(doctest, "_encoding", None) is not None:
from types import FunctionType as __F
__f = doctest.OutputChecker.output_difference.im_func
__g = dict(__f.func_globals)
def _indent(s, indent=4, _pattern=re.compile("^(?!$)", re.MULTILINE)):
"""Prepend non-empty lines in ``s`` with ``indent`` number of spaces"""
return _pattern.sub(indent*" ", s)
Reported by Pylint.
src/third_party/wiredtiger/test/suite/test_cursor06.py
16 issues
Line: 33
Column: 1
# cursors:reconfigure
# [END_TAGS]
import wiredtiger, wttest
from wtdataset import SimpleDataSet, ComplexDataSet, ComplexLSMDataSet
from wtscenario import make_scenarios
# test_cursor06.py
# Test cursor reconfiguration.
Reported by Pylint.
Line: 56
Column: 9
])
def populate(self, uri):
self.ds = self.dataset(self, uri, 100, key_format=self.keyfmt)
self.ds.populate()
def set_kv(self, cursor):
cursor.set_key(self.ds.key(10))
cursor.set_value(self.ds.value(10))
Reported by Pylint.
Line: 72
Column: 17
if open_config != "overwrite=0":
self.set_kv(cursor)
cursor.insert()
for i in range(0, 10):
cursor.reconfigure("overwrite=0")
self.set_kv(cursor)
self.assertRaises(wiredtiger.WiredTigerError,
lambda: cursor.insert())
cursor.reconfigure("overwrite=1")
Reported by Pylint.
Line: 76
Column: 35
cursor.reconfigure("overwrite=0")
self.set_kv(cursor)
self.assertRaises(wiredtiger.WiredTigerError,
lambda: cursor.insert())
cursor.reconfigure("overwrite=1")
self.set_kv(cursor)
cursor.insert()
cursor.close()
Reported by Pylint.
Line: 76
Column: 43
cursor.reconfigure("overwrite=0")
self.set_kv(cursor)
self.assertRaises(wiredtiger.WiredTigerError,
lambda: cursor.insert())
cursor.reconfigure("overwrite=1")
self.set_kv(cursor)
cursor.insert()
cursor.close()
Reported by Pylint.
Line: 92
Column: 43
if open_config == "readonly=1":
self.set_kv(cursor)
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda: cursor.update(), msg)
else:
self.set_kv(cursor)
cursor.update()
cursor.close()
Reported by Pylint.
Line: 92
Column: 35
if open_config == "readonly=1":
self.set_kv(cursor)
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda: cursor.update(), msg)
else:
self.set_kv(cursor)
cursor.update()
cursor.close()
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
Reported by Pylint.
Line: 33
Column: 1
# cursors:reconfigure
# [END_TAGS]
import wiredtiger, wttest
from wtdataset import SimpleDataSet, ComplexDataSet, ComplexLSMDataSet
from wtscenario import make_scenarios
# test_cursor06.py
# Test cursor reconfiguration.
Reported by Pylint.
Line: 39
Column: 1
# test_cursor06.py
# Test cursor reconfiguration.
class test_cursor06(wttest.WiredTigerTestCase):
name = 'reconfigure'
scenarios = make_scenarios([
('file-r', dict(type='file:', keyfmt='r', dataset=SimpleDataSet)),
('file-S', dict(type='file:', keyfmt='S', dataset=SimpleDataSet)),
('lsm-S', dict(type='lsm:', keyfmt='S', dataset=SimpleDataSet)),
Reported by Pylint.
src/third_party/timelib-2021.06/parse_zoneinfo.c
16 issues
Line: 282
CWE codes:
401
if (S_ISDIR(st.st_mode)) {
if (dirstack_top == dirstack_size) {
dirstack_size *= 2;
dirstack = timelib_realloc(dirstack, dirstack_size * sizeof(*dirstack));
}
dirstack[dirstack_top++] = timelib_strdup(name);
} else {
if (index_next == index_size) {
index_size *= 2;
Reported by Cppcheck.
Line: 288
CWE codes:
401
} else {
if (index_next == index_size) {
index_size *= 2;
db_index = timelib_realloc(db_index, index_size * sizeof(timelib_tzdb_index_entry));
}
db_index[index_next].id = timelib_strdup(name);
{
Reported by Cppcheck.
Line: 90
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
static int is_valid_tzfile(const struct stat *st, int fd)
{
if (fd) {
char buf[20];
if (read(fd, buf, 20) != 20) {
return 0;
}
lseek(fd, SEEK_SET, 0);
if (memcmp(buf, "TZif", 4)) {
Reported by FlawFinder.
Line: 130
Column: 7
CWE codes:
362
/* O_BINARY is required to properly read the file on windows */
#ifdef _WIN32
fd = open(fname, O_RDONLY | O_BINARY);
#else
fd = open(fname, O_RDONLY);
#endif
timelib_free(fname);
Reported by FlawFinder.
Line: 132
Column: 7
CWE codes:
362
#ifdef _WIN32
fd = open(fname, O_RDONLY | O_BINARY);
#else
fd = open(fname, O_RDONLY);
#endif
timelib_free(fname);
if (fd == -1) {
return NULL;
Reported by FlawFinder.
Line: 162
Column: 2
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 dirent **entries = NULL;
int entries_size = 0;
int entries_count = 0;
char entry_container[sizeof(struct dirent) + MAXPATHLEN];
struct dirent *entry = (struct dirent *)&entry_container;
dir = opendir(directory_name);
if (!dir) {
return -1;
Reported by FlawFinder.
Line: 204
Column: 48
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
goto cleanup;
}
entries[entries_count++] = (struct dirent *) memcpy(new_entry, entry, new_entry_size);
}
closedir(dir);
*namelist = entries;
Reported by FlawFinder.
Line: 249
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
do {
struct dirent **ents;
char name[PATH_MAX], *top;
int count;
/* Pop the top stack entry, and iterate through its contents. */
top = dirstack[--dirstack_top];
snprintf(name, sizeof(name), "%s/%s", directory, top);
Reported by FlawFinder.
Line: 299
Column: 8
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (tzfile_data) {
tmp_data = timelib_realloc(tmp_data, data_size + length);
memcpy(tmp_data + data_size, tzfile_data, length);
db_index[index_next].pos = data_size;
data_size += length;
timelib_free(tzfile_data);
index_next++;
Reported by FlawFinder.
src/third_party/wiredtiger/test/format/wts.c
16 issues
Line: 293
Column: 40
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
/* Extensions. */
CONFIG_APPEND(p, ",extensions=[\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"],",
g.c_reverse ? REVERSE_PATH : "", access(LZ4_PATH, R_OK) == 0 ? LZ4_PATH : "",
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
Reported by FlawFinder.
Line: 294
Column: 7
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
/* Extensions. */
CONFIG_APPEND(p, ",extensions=[\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"],",
g.c_reverse ? REVERSE_PATH : "", access(LZ4_PATH, R_OK) == 0 ? LZ4_PATH : "",
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
/*
Reported by FlawFinder.
Line: 295
Column: 7
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
CONFIG_APPEND(p, ",extensions=[\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"],",
g.c_reverse ? REVERSE_PATH : "", access(LZ4_PATH, R_OK) == 0 ? LZ4_PATH : "",
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
/*
* Put configuration file configuration options second to last. Put command line configuration
Reported by FlawFinder.
Line: 296
Column: 7
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
g.c_reverse ? REVERSE_PATH : "", access(LZ4_PATH, R_OK) == 0 ? LZ4_PATH : "",
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
/*
* Put configuration file configuration options second to last. Put command line configuration
* options at the end. Do this so they override the standard configuration.
Reported by FlawFinder.
Line: 296
Column: 54
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
g.c_reverse ? REVERSE_PATH : "", access(LZ4_PATH, R_OK) == 0 ? LZ4_PATH : "",
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
/*
* Put configuration file configuration options second to last. Put command line configuration
* options at the end. Do this so they override the standard configuration.
Reported by FlawFinder.
Line: 297
Column: 7
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
access(ROTN_PATH, R_OK) == 0 ? ROTN_PATH : "",
access(SNAPPY_PATH, R_OK) == 0 ? SNAPPY_PATH : "",
access(ZLIB_PATH, R_OK) == 0 ? ZLIB_PATH : "", access(ZSTD_PATH, R_OK) == 0 ? ZSTD_PATH : "",
access(SODIUM_PATH, R_OK) == 0 ? SODIUM_PATH : "");
/*
* Put configuration file configuration options second to last. Put command line configuration
* options at the end. Do this so they override the standard configuration.
*/
Reported by FlawFinder.
Line: 446
Column: 16
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
len = strlen(g.home) * 3 + strlen(FORMAT_HOME_INIT_CMD) + 1;
cmd = dmalloc(len);
testutil_check(__wt_snprintf(cmd, len, FORMAT_HOME_INIT_CMD, g.home, g.home, g.home));
if ((ret = system(cmd)) != 0)
testutil_die(ret, "home initialization (\"%s\") failed", cmd);
free(cmd);
create_database(home, &conn);
create_object(conn);
Reported by FlawFinder.
Line: 186
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
{
WT_CONNECTION *conn;
size_t max;
char config[8 * 1024], *p;
const char *enc;
p = config;
max = sizeof(config);
Reported by FlawFinder.
Line: 326
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
WT_SESSION *session;
size_t max;
uint32_t maxintlkey, maxleafkey, maxleafvalue;
char config[4096], *p;
p = config;
max = sizeof(config);
CONFIG_APPEND(p,
Reported by FlawFinder.
Line: 467
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
{
WT_CONNECTION *conn;
size_t max;
char config[1024], *p;
const char *enc;
*connp = NULL;
*sessionp = NULL;
Reported by FlawFinder.