The following issues were found
src/univalue/lib/univalue_read.cpp
1 issues
Line: 259
Column: 16
CWE codes:
120
20
#define setExpect(bit) (expectMask |= EXP_##bit)
#define clearExpect(bit) (expectMask &= ~EXP_##bit)
bool UniValue::read(const char *raw, size_t size)
{
clear();
uint32_t expectMask = 0;
std::vector<UniValue*> stack;
Reported by FlawFinder.
src/univalue/lib/univalue_get.cpp
1 issues
Line: 25
Column: 23
CWE codes:
126
return false;
if (str.size() >= 1 && (json_isspace(str[0]) || json_isspace(str[str.size()-1]))) // No padding allowed
return false;
if (str.size() != strlen(str.c_str())) // No embedded NUL characters allowed
return false;
return true;
}
bool ParseInt32(const std::string& str, int32_t *out)
Reported by FlawFinder.
src/univalue/lib/univalue_escapes.h
1 issues
Line: 4
Column: 14
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
// Automatically generated file. Do not modify.
#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
static const char *escapes[256] = {
"\\u0000",
"\\u0001",
"\\u0002",
"\\u0003",
"\\u0004",
Reported by FlawFinder.
src/protocol.cpp
1 issues
Line: 92
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn)
{
memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE);
// Copy the command name
size_t i = 0;
for (; i < COMMAND_SIZE && pszCommand[i] != 0; ++i) pchCommand[i] = pszCommand[i];
assert(pszCommand[i] == 0); // Assert that the command name passed in is not longer than COMMAND_SIZE
Reported by FlawFinder.
src/leveldb/util/arena_test.cc
1 issues
Line: 14
class ArenaTest {};
TEST(ArenaTest, Empty) { Arena arena; }
TEST(ArenaTest, Simple) {
std::vector<std::pair<size_t, char*>> allocated;
Arena arena;
const int N = 100000;
Reported by Cppcheck.
src/univalue/gen/gen.cpp
1 issues
Line: 22
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
{
// Escape all lower control characters (some get overridden with smaller sequences below)
for (int ch=0x00; ch<0x20; ++ch) {
char tmpbuf[20];
snprintf(tmpbuf, sizeof(tmpbuf), "\\u%04x", ch);
escapes[ch] = std::string(tmpbuf);
}
escapes[(int)'"'] = "\\\"";
Reported by FlawFinder.
src/uint256.h
1 issues
Line: 105
Column: 11
CWE codes:
120
20
template<typename Stream>
void Unserialize(Stream& s)
{
s.read((char*)m_data, sizeof(m_data));
}
};
/** 160-bit opaque blob.
* @note This type is called uint160 for historical reasons only. It is an opaque
Reported by FlawFinder.
src/leveldb/table/table_builder.cc
1 issues
Line: 184
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
handle->set_size(block_contents.size());
r->status = r->file->Append(block_contents);
if (r->status.ok()) {
char trailer[kBlockTrailerSize];
trailer[0] = type;
uint32_t crc = crc32c::Value(block_contents.data(), block_contents.size());
crc = crc32c::Extend(crc, trailer, 1); // Extend crc to cover block type
EncodeFixed32(trailer + 1, crc32c::Mask(crc));
r->status = r->file->Append(Slice(trailer, kBlockTrailerSize));
Reported by FlawFinder.
src/torcontrol.cpp
1 issues
Line: 86
Column: 30
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
if (s.size() < 4) // Short line
continue;
// <status>(-|+| )<data><CRLF>
self->message.code = atoi(s.substr(0,3));
self->message.lines.push_back(s.substr(4));
char ch = s[3]; // '-','+' or ' '
if (ch == ' ') {
// Final line, dispatch reply and clean up
if (self->message.code >= 600) {
Reported by FlawFinder.
src/test/validation_tests.cpp
1 issues
Line: 15
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(validation_tests, TestingSetup)
static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams)
{
int maxHalvings = 64;
CAmount nInitialSubsidy = 50 * COIN;
Reported by Cppcheck.