diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 796890d..5216d92 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -350,7 +350,7 @@ void p2pool::submit_block() const [height, diff, &submit_data](const char* data, size_t size) { rapidjson::Document doc; - if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { + if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { LOGERR(0, "submit_block: invalid JSON response from daemon"); return; } @@ -542,7 +542,7 @@ void p2pool::get_info() void p2pool::parse_get_info_rpc(const char* data, size_t size) { rapidjson::Document doc; - doc.Parse(data, size); + doc.Parse(data, size); if (!doc.IsObject() || !doc.HasMember("result")) { LOGWARN(1, "get_info RPC response is invalid (\"result\" not found), trying again in 1 second"); @@ -599,7 +599,7 @@ void p2pool::get_miner_data() void p2pool::parse_get_miner_data_rpc(const char* data, size_t size) { rapidjson::Document doc; - doc.Parse(data, size); + doc.Parse(data, size); if (!doc.IsObject() || !doc.HasMember("result")) { LOGWARN(1, "get_miner_data RPC response is invalid, skipping it"); @@ -647,7 +647,7 @@ void p2pool::parse_get_miner_data_rpc(const char* data, size_t size) bool p2pool::parse_block_header(const char* data, size_t size, ChainMain& result) { rapidjson::Document doc; - if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { + if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { LOGERR(1, "parse_block_header: invalid JSON response from daemon"); return false; } @@ -682,7 +682,7 @@ bool p2pool::parse_block_header(const char* data, size_t size, ChainMain& result uint32_t p2pool::parse_block_headers_range(const char* data, size_t size) { rapidjson::Document doc; - if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { + if (doc.Parse(data, size).HasParseError() || !doc.IsObject()) { LOGERR(1, "parse_block_headers_range: invalid JSON response from daemon"); return 0; } diff --git a/src/side_chain.cpp b/src/side_chain.cpp index c6b5517..28e71a0 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -1493,7 +1493,7 @@ bool SideChain::load_config(const std::string& filename) rapidjson::Document doc; rapidjson::IStreamWrapper s(f); - if (doc.ParseStream(s).HasParseError()) { + if (doc.ParseStream(s).HasParseError()) { LOGERR(1, "failed to parse JSON data in " << filename); return false; } diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index 4d96253..12452da 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -143,7 +143,10 @@ void ZMQReader::parse(char* data, size_t size) using namespace rapidjson; Document doc; - doc.Parse(value, end - value); + if (doc.Parse(value, end - value).HasParseError()) { + LOGWARN(1, "ZeroMQ message failed to parse, skipping it"); + return; + } if (strcmp(data, "json-minimal-txpool_add") == 0) { if (!doc.IsArray()) {