The following issues were found
src/third_party/wiredtiger/test/suite/test_drop.py
12 issues
Line: 30
Column: 1
# OTHER DEALINGS IN THE SOFTWARE.
import os, time
import wiredtiger, wttest
from helper import confirm_does_not_exist
from wtdataset import SimpleDataSet, ComplexDataSet
from wtscenario import make_scenarios
# test_drop.py
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 os, time
import wiredtiger, wttest
from helper import confirm_does_not_exist
from wtdataset import SimpleDataSet, ComplexDataSet
from wtscenario import make_scenarios
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 os, time
import wiredtiger, wttest
from helper import confirm_does_not_exist
from wtdataset import SimpleDataSet, ComplexDataSet
from wtscenario import make_scenarios
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 os, time
import wiredtiger, wttest
from helper import confirm_does_not_exist
from wtdataset import SimpleDataSet, ComplexDataSet
from wtscenario import make_scenarios
Reported by Pylint.
Line: 30
Column: 1
# OTHER DEALINGS IN THE SOFTWARE.
import os, time
import wiredtiger, wttest
from helper import confirm_does_not_exist
from wtdataset import SimpleDataSet, ComplexDataSet
from wtscenario import make_scenarios
# test_drop.py
Reported by Pylint.
Line: 37
Column: 1
# test_drop.py
# session level drop operation
class test_drop(wttest.WiredTigerTestCase):
name = 'test_drop'
extra_config = ''
scenarios = make_scenarios([
('file', dict(uri='file:')),
Reported by Pylint.
Line: 37
Column: 1
# test_drop.py
# session level drop operation
class test_drop(wttest.WiredTigerTestCase):
name = 'test_drop'
extra_config = ''
scenarios = make_scenarios([
('file', dict(uri='file:')),
Reported by Pylint.
Line: 48
Column: 5
])
# Populate an object, remove it and confirm it no longer exists.
def drop(self, dataset, with_cursor, reopen, drop_index):
uri = self.uri + self.name
ds = dataset(self, uri, 10, config=self.extra_config)
ds.populate()
# Open cursors should cause failure.
Reported by Pylint.
Line: 50
Column: 9
# Populate an object, remove it and confirm it no longer exists.
def drop(self, dataset, with_cursor, reopen, drop_index):
uri = self.uri + self.name
ds = dataset(self, uri, 10, config=self.extra_config)
ds.populate()
# Open cursors should cause failure.
if with_cursor:
cursor = self.session.open_cursor(uri, None, None)
Reported by Pylint.
src/third_party/wiredtiger/src/utilities/util_dump.c
12 issues
Line: 289
CWE codes:
908
ret = util_err(session, ret, "%s", uri);
if ((tret = mcursor->close(mcursor)) != 0) {
tret = util_cerr(mcursor, "close", tret);
if (ret == 0)
ret = tret;
}
return (ret);
Reported by Cppcheck.
Line: 351
Column: 33
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
static int
dump_add_config(WT_SESSION *session, char **bufp, size_t *leftp, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format(printf, 4, 5)))
{
WT_DECL_RET;
size_t n;
va_list ap;
Reported by FlawFinder.
Line: 129
Column: 20
CWE codes:
362
/* Open any optional output file. */
if (ofile == NULL)
fp = stdout;
else if ((fp = fopen(ofile, "w")) == NULL)
return (util_err(session, errno, "%s: open", ofile));
if (json && (dump_json_begin(session) != 0 || dump_prefix(session, pretty, hex, json) != 0))
goto err;
Reported by FlawFinder.
Line: 383
Column: 59
CWE codes:
126
char *newconfig;
const char *keyformat, *p;
len = strlen(config) + strlen(cursor->value_format) + strlen(cursor->uri) + 20;
if ((newconfig = malloc(len)) == NULL)
return (util_err(session, errno, NULL));
*newconfigp = newconfig;
wt_api = session->connection->get_extension_api(session->connection);
if ((ret = wt_api->config_parser_open(wt_api, session, config, strlen(config), &parser)) != 0)
Reported by FlawFinder.
Line: 383
Column: 11
CWE codes:
126
char *newconfig;
const char *keyformat, *p;
len = strlen(config) + strlen(cursor->value_format) + strlen(cursor->uri) + 20;
if ((newconfig = malloc(len)) == NULL)
return (util_err(session, errno, NULL));
*newconfigp = newconfig;
wt_api = session->connection->get_extension_api(session->connection);
if ((ret = wt_api->config_parser_open(wt_api, session, config, strlen(config), &parser)) != 0)
Reported by FlawFinder.
Line: 383
Column: 28
CWE codes:
126
char *newconfig;
const char *keyformat, *p;
len = strlen(config) + strlen(cursor->value_format) + strlen(cursor->uri) + 20;
if ((newconfig = malloc(len)) == NULL)
return (util_err(session, errno, NULL));
*newconfigp = newconfig;
wt_api = session->connection->get_extension_api(session->connection);
if ((ret = wt_api->config_parser_open(wt_api, session, config, strlen(config), &parser)) != 0)
Reported by FlawFinder.
Line: 388
Column: 68
CWE codes:
126
return (util_err(session, errno, NULL));
*newconfigp = newconfig;
wt_api = session->connection->get_extension_api(session->connection);
if ((ret = wt_api->config_parser_open(wt_api, session, config, strlen(config), &parser)) != 0)
return (util_err(session, ret, "WT_EXTENSION_API.config_parser_open"));
keyformat = cursor->key_format;
for (nkeys = 0; *keyformat; keyformat++)
if (!__wt_isdigit((u_char)*keyformat))
nkeys++;
Reported by FlawFinder.
Line: 418
Column: 22
CWE codes:
126
/* copy names of projected values */
p = strchr(cursor->uri, '(');
assert(p != NULL);
assert(p[strlen(p) - 1] == ')');
p++;
if (*p != ')')
WT_RET(dump_add_config(session, &newconfig, &len, "%s", ","));
WT_RET(dump_add_config(session, &newconfig, &len, "%.*s),", (int)(strlen(p) - 1), p));
} else if (value.type == WT_CONFIG_ITEM_STRING && value.len != 0)
Reported by FlawFinder.
Line: 422
Column: 79
CWE codes:
126
p++;
if (*p != ')')
WT_RET(dump_add_config(session, &newconfig, &len, "%s", ","));
WT_RET(dump_add_config(session, &newconfig, &len, "%.*s),", (int)(strlen(p) - 1), p));
} else if (value.type == WT_CONFIG_ITEM_STRING && value.len != 0)
WT_RET(
dump_add_config(session, &newconfig, &len, "\"%.*s\",", (int)value.len, value.str));
else
WT_RET(dump_add_config(session, &newconfig, &len, "%.*s,", (int)value.len, value.str));
Reported by FlawFinder.
Line: 514
Column: 27
CWE codes:
126
return (util_err(session, EIO, NULL));
}
len = strlen(entry) + strlen(name) + 1;
if ((uriprefix = malloc(len)) == NULL)
return (util_err(session, errno, NULL));
if ((ret = __wt_snprintf(uriprefix, len, "%s%s", entry, name)) != 0) {
free(uriprefix);
return (util_err(session, ret, NULL));
Reported by FlawFinder.
src/third_party/wiredtiger/src/support/err.c
12 issues
Line: 282
Column: 13
CWE codes:
134
Suggestion:
Use a constant for the format specification
if (fprintf(stderr, "WiredTiger Error%s%s: ", error == 0 ? "" : ": ",
error == 0 ? "" : __wt_strerror(session, error, NULL, 0)) < 0)
WT_TRET(EIO);
if (vfprintf(stderr, fmt, ap) < 0)
WT_TRET(EIO);
if (fprintf(stderr, "\n") < 0)
WT_TRET(EIO);
if (fflush(stderr) != 0)
WT_TRET(EIO);
Reported by FlawFinder.
Line: 299
Column: 63
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
void
__wt_err_func(WT_SESSION_IMPL *session, int error, const char *func, int line, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((cold)) WT_GCC_FUNC_ATTRIBUTE((format(printf, 5, 6)))
WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
va_list ap;
/*
Reported by FlawFinder.
Line: 319
Column: 63
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
void
__wt_errx_func(WT_SESSION_IMPL *session, const char *func, int line, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((cold)) WT_GCC_FUNC_ATTRIBUTE((format(printf, 4, 5)))
WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
va_list ap;
/*
Reported by FlawFinder.
Line: 339
Column: 68
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
int
__wt_panic_func(WT_SESSION_IMPL *session, int error, const char *func, int line, const char *fmt,
...) WT_GCC_FUNC_ATTRIBUTE((cold)) WT_GCC_FUNC_ATTRIBUTE((format(printf, 5, 6)))
WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
WT_CONNECTION_IMPL *conn;
va_list ap;
Reported by FlawFinder.
Line: 424
Column: 33
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
int
__wt_ext_err_printf(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format(printf, 3, 4)))
{
WT_DECL_RET;
WT_SESSION_IMPL *session;
va_list ap;
Reported by FlawFinder.
Line: 445
Column: 33
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
void
__wt_verbose_worker(WT_SESSION_IMPL *session, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format(printf, 2, 3))) WT_GCC_FUNC_ATTRIBUTE((cold))
{
va_list ap;
va_start(ap, fmt);
WT_IGNORE_RET(__eventv(session, true, 0, NULL, 0, fmt, ap));
Reported by FlawFinder.
Line: 460
Column: 33
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
int
__wt_msg(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_ATTRIBUTE((cold))
WT_GCC_FUNC_ATTRIBUTE((format(printf, 2, 3)))
{
WT_DECL_ITEM(buf);
WT_DECL_RET;
WT_EVENT_HANDLER *handler;
WT_SESSION *wt_session;
Reported by FlawFinder.
Line: 486
Column: 33
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
int
__wt_ext_msg_printf(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format(printf, 3, 4)))
{
WT_DECL_ITEM(buf);
WT_DECL_RET;
WT_EVENT_HANDLER *handler;
WT_SESSION_IMPL *session;
Reported by FlawFinder.
Line: 96
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
* SECURITY:
* Buffer placed at the end of the stack in case snprintf overflows.
*/
char s[256];
if (__wt_snprintf(s, sizeof(s), "application %s event handler failed: %s", which,
__wt_strerror(session, error, NULL, 0)) != 0)
return;
Reported by FlawFinder.
Line: 177
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_EVENT_HANDLER *handler;
WT_SESSION *wt_session;
size_t len, remain;
char *p, tid[128];
const char *err, *prefix;
/*
* We're using a stack buffer because we want error messages no matter
* what, and allocating a WT_ITEM, or the memory it needs, might fail.
Reported by FlawFinder.
src/third_party/wiredtiger/test/3rdparty/testtools-0.9.34/testtools/tests/test_tags.py
12 issues
Line: 10
Column: 1
from testtools.tags import TagContext
class TestTags(TestCase):
def test_no_tags(self):
# A tag context has no tags initially.
tag_context = TagContext()
self.assertEqual(set(), tag_context.get_current_tags())
Reported by Pylint.
Line: 12
Column: 5
class TestTags(TestCase):
def test_no_tags(self):
# A tag context has no tags initially.
tag_context = TagContext()
self.assertEqual(set(), tag_context.get_current_tags())
def test_add_tag(self):
Reported by Pylint.
Line: 17
Column: 5
tag_context = TagContext()
self.assertEqual(set(), tag_context.get_current_tags())
def test_add_tag(self):
# A tag added with change_tags appears in get_current_tags.
tag_context = TagContext()
tag_context.change_tags(set(['foo']), set())
self.assertEqual(set(['foo']), tag_context.get_current_tags())
Reported by Pylint.
Line: 23
Column: 5
tag_context.change_tags(set(['foo']), set())
self.assertEqual(set(['foo']), tag_context.get_current_tags())
def test_add_tag_twice(self):
# Calling change_tags twice to add tags adds both tags to the current
# tags.
tag_context = TagContext()
tag_context.change_tags(set(['foo']), set())
tag_context.change_tags(set(['bar']), set())
Reported by Pylint.
Line: 32
Column: 5
self.assertEqual(
set(['foo', 'bar']), tag_context.get_current_tags())
def test_change_tags_returns_tags(self):
# change_tags returns the current tags. This is a convenience.
tag_context = TagContext()
tags = tag_context.change_tags(set(['foo']), set())
self.assertEqual(set(['foo']), tags)
Reported by Pylint.
Line: 38
Column: 5
tags = tag_context.change_tags(set(['foo']), set())
self.assertEqual(set(['foo']), tags)
def test_remove_tag(self):
# change_tags can remove tags from the context.
tag_context = TagContext()
tag_context.change_tags(set(['foo']), set())
tag_context.change_tags(set(), set(['foo']))
self.assertEqual(set(), tag_context.get_current_tags())
Reported by Pylint.
Line: 45
Column: 5
tag_context.change_tags(set(), set(['foo']))
self.assertEqual(set(), tag_context.get_current_tags())
def test_child_context(self):
# A TagContext can have a parent. If so, its tags are the tags of the
# parent at the moment of construction.
parent = TagContext()
parent.change_tags(set(['foo']), set())
child = TagContext(parent)
Reported by Pylint.
Line: 54
Column: 5
self.assertEqual(
parent.get_current_tags(), child.get_current_tags())
def test_add_to_child(self):
# Adding a tag to the child context doesn't affect the parent.
parent = TagContext()
parent.change_tags(set(['foo']), set())
child = TagContext(parent)
child.change_tags(set(['bar']), set())
Reported by Pylint.
Line: 63
Column: 5
self.assertEqual(set(['foo', 'bar']), child.get_current_tags())
self.assertEqual(set(['foo']), parent.get_current_tags())
def test_remove_in_child(self):
# A tag that was in the parent context can be removed from the child
# context without affect the parent.
parent = TagContext()
parent.change_tags(set(['foo']), set())
child = TagContext(parent)
Reported by Pylint.
Line: 73
Column: 5
self.assertEqual(set(), child.get_current_tags())
self.assertEqual(set(['foo']), parent.get_current_tags())
def test_parent(self):
# The parent can be retrieved from a child context.
parent = TagContext()
parent.change_tags(set(['foo']), set())
child = TagContext(parent)
child.change_tags(set(), set(['foo']))
Reported by Pylint.
src/third_party/wiredtiger/src/support/timestamp.c
12 issues
Line: 31
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_time_point_to_string(
wt_timestamp_t ts, wt_timestamp_t durable_ts, uint64_t txn_id, char *tp_string)
{
char ts_string[WT_TS_INT_STRING_SIZE];
WT_IGNORE_RET(__wt_snprintf(tp_string, WT_TP_STRING_SIZE, "%s/%s/%" PRIu64,
__wt_timestamp_to_string(ts, ts_string), __wt_timestamp_to_string(durable_ts, ts_string),
txn_id));
return (tp_string);
Reported by FlawFinder.
Line: 46
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
char *
__wt_time_window_to_string(WT_TIME_WINDOW *tw, char *tw_string)
{
char ts_string[4][WT_TS_INT_STRING_SIZE];
WT_IGNORE_RET(__wt_snprintf(tw_string, WT_TIME_STRING_SIZE,
"start: %s/%s/%" PRIu64 " stop: %s/%s/%" PRIu64 "%s",
__wt_timestamp_to_string(tw->durable_start_ts, ts_string[0]),
__wt_timestamp_to_string(tw->start_ts, ts_string[1]), tw->start_txn,
Reported by FlawFinder.
Line: 65
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
char *
__wt_time_aggregate_to_string(WT_TIME_AGGREGATE *ta, char *ta_string)
{
char ts_string[4][WT_TS_INT_STRING_SIZE];
WT_IGNORE_RET(__wt_snprintf(ta_string, WT_TIME_STRING_SIZE,
"newest durable: %s/%s oldest start: %s/%" PRIu64 " newest stop %s/%" PRIu64 "%s",
__wt_timestamp_to_string(ta->newest_start_durable_ts, ts_string[0]),
__wt_timestamp_to_string(ta->newest_stop_durable_ts, ts_string[1]),
Reported by FlawFinder.
Line: 93
Column: 15
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
if (ts == WT_TS_MAX) {
#define WT_TS_MAX_HEX_STRING "ffffffffffffffff"
(void)memcpy(hex_timestamp, WT_TS_MAX_HEX_STRING, strlen(WT_TS_MAX_HEX_STRING) + 1);
return;
}
for (p = hex_timestamp; ts != 0; ts >>= 4)
*p++ = (char)__wt_hex((u_char)(ts & 0x0f));
Reported by FlawFinder.
Line: 116
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
void
__wt_verbose_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t ts, const char *msg)
{
char ts_string[WT_TS_INT_STRING_SIZE];
__wt_verbose(
session, WT_VERB_TIMESTAMP, "Timestamp %s: %s", __wt_timestamp_to_string(ts, ts_string), msg);
}
Reported by FlawFinder.
Line: 161
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_IMPL *session, WT_TIME_AGGREGATE *ta, bool silent)
{
wt_timestamp_t stable;
char time_string[WT_TIME_STRING_SIZE], ts_string[WT_TS_INT_STRING_SIZE];
stable = __time_stable(session);
if (ta->newest_start_durable_ts > stable)
WT_TIME_ERROR("a newest start durable time after");
Reported by FlawFinder.
Line: 185
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
__time_aggregate_validate_parent(
WT_SESSION_IMPL *session, WT_TIME_AGGREGATE *ta, WT_TIME_AGGREGATE *parent, bool silent)
{
char time_string[2][WT_TIME_STRING_SIZE];
if (ta->newest_start_durable_ts > parent->newest_start_durable_ts)
WT_TIME_VALIDATE_RET(session,
"aggregate time window has a newest start durable time after its parent's; time "
"aggregate %s, parent %s",
Reported by FlawFinder.
Line: 246
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_time_aggregate_validate(
WT_SESSION_IMPL *session, WT_TIME_AGGREGATE *ta, WT_TIME_AGGREGATE *parent, bool silent)
{
char time_string[2][WT_TIME_STRING_SIZE];
if (ta->oldest_start_ts > ta->newest_stop_ts)
WT_TIME_VALIDATE_RET(session,
"aggregate time window has an oldest start time after its newest stop time; time "
"aggregate %s",
Reported by FlawFinder.
Line: 322
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
__time_value_validate_parent_stable(WT_SESSION_IMPL *session, WT_TIME_WINDOW *tw, bool silent)
{
wt_timestamp_t stable;
char time_string[WT_TIME_STRING_SIZE], ts_string[WT_TS_INT_STRING_SIZE];
stable = __time_stable(session);
if (tw->durable_start_ts > stable)
WT_TIME_ERROR("a durable start time after");
Reported by FlawFinder.
Line: 346
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
__time_value_validate_parent(
WT_SESSION_IMPL *session, WT_TIME_WINDOW *tw, WT_TIME_AGGREGATE *parent, bool silent)
{
char time_string[2][WT_TIME_STRING_SIZE];
if (parent->newest_start_durable_ts != WT_TS_NONE &&
tw->durable_start_ts > parent->newest_start_durable_ts)
WT_TIME_VALIDATE_RET(session,
"value time window has a durable start time after its parent's newest durable start "
Reported by FlawFinder.
src/mongo/base/data_view_test.cpp
12 issues
Line: 60
ASSERT_EQUALS(native, cdv.read<BigEndian<uint32_t>>(sizeof(uint32_t) * 2));
}
TEST(DataView, DataView) {
char buf[sizeof(uint32_t) * 3];
uint32_t native = 1234;
DataView dv(buf);
Reported by Cppcheck.
Line: 41
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
namespace mongo {
TEST(DataView, ConstDataView) {
char buf[sizeof(uint32_t) * 3];
uint32_t native = 1234;
uint32_t le = endian::nativeToLittle(native);
uint32_t be = endian::nativeToBig(native);
std::memcpy(buf, &native, sizeof(uint32_t));
Reported by FlawFinder.
Line: 46
Column: 10
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
uint32_t le = endian::nativeToLittle(native);
uint32_t be = endian::nativeToBig(native);
std::memcpy(buf, &native, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t), &le, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t) * 2, &be, sizeof(uint32_t));
ConstDataView cdv(buf);
Reported by FlawFinder.
Line: 47
Column: 10
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
uint32_t be = endian::nativeToBig(native);
std::memcpy(buf, &native, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t), &le, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t) * 2, &be, sizeof(uint32_t));
ConstDataView cdv(buf);
ASSERT_EQUALS(buf, cdv.view());
Reported by FlawFinder.
Line: 48
Column: 10
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
std::memcpy(buf, &native, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t), &le, sizeof(uint32_t));
std::memcpy(buf + sizeof(uint32_t) * 2, &be, sizeof(uint32_t));
ConstDataView cdv(buf);
ASSERT_EQUALS(buf, cdv.view());
ASSERT_EQUALS(buf + 5, cdv.view(5));
Reported by FlawFinder.
Line: 61
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
}
TEST(DataView, DataView) {
char buf[sizeof(uint32_t) * 3];
uint32_t native = 1234;
DataView dv(buf);
dv.write(native);
Reported by FlawFinder.
Line: 55
Column: 31
CWE codes:
120
20
ASSERT_EQUALS(buf, cdv.view());
ASSERT_EQUALS(buf + 5, cdv.view(5));
ASSERT_EQUALS(native, cdv.read<uint32_t>());
ASSERT_EQUALS(native, cdv.read<LittleEndian<uint32_t>>(sizeof(uint32_t)));
ASSERT_EQUALS(native, cdv.read<BigEndian<uint32_t>>(sizeof(uint32_t) * 2));
}
TEST(DataView, DataView) {
Reported by FlawFinder.
Line: 56
Column: 31
CWE codes:
120
20
ASSERT_EQUALS(buf + 5, cdv.view(5));
ASSERT_EQUALS(native, cdv.read<uint32_t>());
ASSERT_EQUALS(native, cdv.read<LittleEndian<uint32_t>>(sizeof(uint32_t)));
ASSERT_EQUALS(native, cdv.read<BigEndian<uint32_t>>(sizeof(uint32_t) * 2));
}
TEST(DataView, DataView) {
char buf[sizeof(uint32_t) * 3];
Reported by FlawFinder.
Line: 57
Column: 31
CWE codes:
120
20
ASSERT_EQUALS(native, cdv.read<uint32_t>());
ASSERT_EQUALS(native, cdv.read<LittleEndian<uint32_t>>(sizeof(uint32_t)));
ASSERT_EQUALS(native, cdv.read<BigEndian<uint32_t>>(sizeof(uint32_t) * 2));
}
TEST(DataView, DataView) {
char buf[sizeof(uint32_t) * 3];
uint32_t native = 1234;
Reported by FlawFinder.
Line: 73
Column: 30
CWE codes:
120
20
ASSERT_EQUALS(buf, dv.view());
ASSERT_EQUALS(buf + 5, dv.view(5));
ASSERT_EQUALS(native, dv.read<uint32_t>());
ASSERT_EQUALS(native, dv.read<LittleEndian<uint32_t>>(sizeof(uint32_t)));
ASSERT_EQUALS(native, dv.read<BigEndian<uint32_t>>(sizeof(uint32_t) * 2));
}
} // namespace mongo
Reported by FlawFinder.
src/third_party/wiredtiger/test/3rdparty/python-subunit-0.0.16/python/subunit/chunked.py
12 issues
Line: 20
Column: 1
"""Encoder/decoder for http style chunked encoding."""
from testtools.compat import _b
empty = _b('')
class Decoder(object):
"""Decode chunked content to a byte stream."""
Reported by Pylint.
Line: 60
Column: 12
:raises ValueError: If the stream is incomplete ValueError is raised.
"""
if self.state != self._finished:
raise ValueError("incomplete stream")
def _finished(self):
"""Finished reading, return any remaining bytes."""
if self.buffered_bytes:
Reported by Pylint.
Line: 93
Column: 13
def _read_length(self):
"""Try to decode a length from the bytes."""
count_chars = []
for bytes in self.buffered_bytes:
for pos in range(len(bytes)):
byte = bytes[pos:pos+1]
if byte not in self._match_chars:
break
count_chars.append(byte)
Reported by Pylint.
Line: 129
Column: 21
self.state = self._read_body
return self.state()
def write(self, bytes):
"""Decode bytes to the output stream.
:raises ValueError: If the stream has already seen the end of file
marker.
:returns: None, or the excess bytes beyond the end of file marker.
Reported by Pylint.
Line: 172
Column: 21
self.output.write(empty.join(buffered_bytes))
return True
def write(self, bytes):
"""Encode bytes to the output stream."""
bytes_len = len(bytes)
if self.buffer_size + bytes_len >= 65536:
self.flush(bytes_len)
self.output.write(bytes)
Reported by Pylint.
Line: 24
Column: 1
empty = _b('')
class Decoder(object):
"""Decode chunked content to a byte stream."""
def __init__(self, output, strict=True):
"""Create a decoder decoding to output.
Reported by Pylint.
Line: 24
Column: 1
empty = _b('')
class Decoder(object):
"""Decode chunked content to a byte stream."""
def __init__(self, output, strict=True):
"""Create a decoder decoding to output.
Reported by Pylint.
Line: 65
Column: 9
def _finished(self):
"""Finished reading, return any remaining bytes."""
if self.buffered_bytes:
buffered_bytes = self.buffered_bytes
self.buffered_bytes = []
return empty.join(buffered_bytes)
else:
raise ValueError("stream is finished")
Reported by Pylint.
Line: 90
Column: 5
self.state = self._read_length
return self.state()
def _read_length(self):
"""Try to decode a length from the bytes."""
count_chars = []
for bytes in self.buffered_bytes:
for pos in range(len(bytes)):
byte = bytes[pos:pos+1]
Reported by Pylint.
Line: 90
Column: 5
self.state = self._read_length
return self.state()
def _read_length(self):
"""Try to decode a length from the bytes."""
count_chars = []
for bytes in self.buffered_bytes:
for pos in range(len(bytes)):
byte = bytes[pos:pos+1]
Reported by Pylint.
src/third_party/wiredtiger/test/suite/test_bug023.py
12 issues
Line: 33
Column: 1
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
# test_bug023.py
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
# then leaves the database in an incorrect state so that the next wiredtiger_open
# without an error loses data.
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.
from helper import copy_wiredtiger_home
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
Reported by Pylint.
Line: 49
Column: 32
nentries = 10
uri = 'file:bug023.wt'
def take_full_backup(self, dir):
# Open up the backup cursor, and copy the files. Do a full backup.
cursor = self.session.open_cursor('backup:', None, None)
self.pr('Full backup to ' + dir + ': ')
os.mkdir(dir)
while True:
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: 31
Column: 1
from helper import copy_wiredtiger_home
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
# test_bug023.py
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
Reported by Pylint.
Line: 32
Column: 1
from helper import copy_wiredtiger_home
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
# test_bug023.py
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
# then leaves the database in an incorrect state so that the next wiredtiger_open
Reported by Pylint.
Line: 33
Column: 1
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
# test_bug023.py
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
# then leaves the database in an incorrect state so that the next wiredtiger_open
# without an error loses data.
Reported by Pylint.
Line: 33
Column: 1
from suite_subprocess import suite_subprocess
import os
import shutil
import wiredtiger, wttest
# test_bug023.py
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
# then leaves the database in an incorrect state so that the next wiredtiger_open
# without an error loses data.
Reported by Pylint.
Line: 39
Column: 1
# JIRA WT-5930: starting up a backup database with an error in wiredtiger_open
# then leaves the database in an incorrect state so that the next wiredtiger_open
# without an error loses data.
class test_bug023(wttest.WiredTigerTestCase, suite_subprocess):
'''Test backup, compatibility levels and an error opening the backup'''
conn_config = 'config_base=false,log=(enabled),compatibility=(release=3.2.0)'
conn_config_32_min = 'config_base=false,log=(enabled),compatibility=(require_min=3.2.0)'
conn_config_33_err = 'config_base=false,log=(enabled),compatibility=(require_min=3.3.0)'
Reported by Pylint.
Line: 49
Column: 5
nentries = 10
uri = 'file:bug023.wt'
def take_full_backup(self, dir):
# Open up the backup cursor, and copy the files. Do a full backup.
cursor = self.session.open_cursor('backup:', None, None)
self.pr('Full backup to ' + dir + ': ')
os.mkdir(dir)
while True:
Reported by Pylint.
src/third_party/abseil-cpp-master/abseil-cpp/absl/container/internal/raw_hash_set_probe_benchmark.cc
12 issues
Line: 247
struct String {
std::string value;
static std::string Make(uint32_t v) {
return {small ? absl::StrCat(v) : absl::StrFormat(kStringFormat, v)};
}
};
template <>
struct DefaultHash<IntIdentity> {
Reported by Cppcheck.
Line: 247
Column: 27
CWE codes:
120
struct String {
std::string value;
static std::string Make(uint32_t v) {
return {small ? absl::StrCat(v) : absl::StrFormat(kStringFormat, v)};
}
};
template <>
struct DefaultHash<IntIdentity> {
Reported by FlawFinder.
Line: 409
Column: 16
CWE codes:
120
template <int Align>
std::string Name(Ptr<Align>**) {
return absl::StrCat("Ptr", Align);
}
template <int Align>
std::string Name(PtrIdentity<Align>*) {
return absl::StrCat("PtrIdentity", Align);
Reported by FlawFinder.
Line: 414
Column: 16
CWE codes:
120
template <int Align>
std::string Name(PtrIdentity<Align>*) {
return absl::StrCat("PtrIdentity", Align);
}
template <bool small>
std::string Name(String<small>*) {
return small ? "StrS" : "StrL";
Reported by FlawFinder.
Line: 425
Column: 18
CWE codes:
120
template <class T, class U>
std::string Name(std::pair<T, U>*) {
if (output() == OutputStyle::kBenchmark)
return absl::StrCat("P_", Name<T>(), "_", Name<U>());
return absl::StrCat("P<", Name<T>(), ",", Name<U>(), ">");
}
template <class T>
std::string Name(Sequential<T>*) {
Reported by FlawFinder.
Line: 426
Column: 16
CWE codes:
120
std::string Name(std::pair<T, U>*) {
if (output() == OutputStyle::kBenchmark)
return absl::StrCat("P_", Name<T>(), "_", Name<U>());
return absl::StrCat("P<", Name<T>(), ",", Name<U>(), ">");
}
template <class T>
std::string Name(Sequential<T>*) {
return "Sequential";
Reported by FlawFinder.
Line: 436
Column: 16
CWE codes:
120
template <class T, int P>
std::string Name(AlmostSequential<T, P>*) {
return absl::StrCat("AlmostSeq_", P);
}
template <class T>
std::string Name(Random<T, Uniform>*) {
return "UnifRand";
Reported by FlawFinder.
Line: 479
Column: 28
CWE codes:
120
template <typename T, typename Dist>
void RunForTypeAndDistribution(std::vector<Result>& results) {
std::string name = absl::StrCat(Name<T>(), "/", Name<Dist>());
// We have to check against all three names (min/avg/max) before we run it.
// If any of them is enabled, we run it.
if (!CanRunBenchmark(absl::StrCat(name, "/min")) &&
!CanRunBenchmark(absl::StrCat(name, "/avg")) &&
!CanRunBenchmark(absl::StrCat(name, "/max"))) {
Reported by FlawFinder.
Line: 482
Column: 30
CWE codes:
120
std::string name = absl::StrCat(Name<T>(), "/", Name<Dist>());
// We have to check against all three names (min/avg/max) before we run it.
// If any of them is enabled, we run it.
if (!CanRunBenchmark(absl::StrCat(name, "/min")) &&
!CanRunBenchmark(absl::StrCat(name, "/avg")) &&
!CanRunBenchmark(absl::StrCat(name, "/max"))) {
return;
}
results.push_back({Name<T>(), Name<Dist>(), CollectMeanProbeLengths<Dist>()});
Reported by FlawFinder.
Line: 483
Column: 30
CWE codes:
120
// We have to check against all three names (min/avg/max) before we run it.
// If any of them is enabled, we run it.
if (!CanRunBenchmark(absl::StrCat(name, "/min")) &&
!CanRunBenchmark(absl::StrCat(name, "/avg")) &&
!CanRunBenchmark(absl::StrCat(name, "/max"))) {
return;
}
results.push_back({Name<T>(), Name<Dist>(), CollectMeanProbeLengths<Dist>()});
}
Reported by FlawFinder.
src/third_party/wiredtiger/test/suite/test_txn18.py
12 issues
Line: 35
Column: 1
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn18'
conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
Reported by Pylint.
Line: 33
Column: 1
# Transactions: test recovery settings
#
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
Reported by Pylint.
Line: 33
Column: 1
# Transactions: test recovery settings
#
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
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
# Transactions: test recovery settings
#
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
Reported by Pylint.
Line: 35
Column: 1
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn18'
conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
Reported by Pylint.
Line: 35
Column: 1
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn18'
conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
Reported by Pylint.
Line: 38
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn18'
conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
'transaction_sync=(method=dsync,enabled)'
conn_recerror = conn_config + ',log=(recover=error)'
conn_recon = conn_config + ',log=(recover=on)'
Reported by Pylint.
Line: 38
Column: 1
import wiredtiger, wttest
from wtscenario import make_scenarios
class test_txn18(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn18'
conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
'transaction_sync=(method=dsync,enabled)'
conn_recerror = conn_config + ',log=(recover=error)'
conn_recon = conn_config + ',log=(recover=on)'
Reported by Pylint.
Line: 51
Column: 5
]
scenarios = make_scenarios(key_format_values)
def simulate_crash(self, olddir, newdir):
''' Simulate a crash from olddir and restart in newdir. '''
# with the connection still open, copy files to new directory
shutil.rmtree(newdir, ignore_errors=True)
os.mkdir(newdir)
for fname in os.listdir(olddir):
Reported by Pylint.