Check message identifier in RPCSession

This commit is contained in:
Alex Beregszaszi 2019-01-30 12:57:25 +00:00
parent 110b9a6232
commit e1780e3ae8

View File

@ -326,6 +326,14 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const&
if (!jsonParseStrict(reply, result, &errorMsg))
BOOST_REQUIRE_MESSAGE(false, errorMsg);
if (!result.isMember("id") || !result["id"].isUInt())
BOOST_FAIL("Badly formatted JSON-RPC response (missing or non-integer \"id\")");
if (result["id"].asUInt() != (m_rpcSequence - 1))
BOOST_FAIL(
"Response identifier mismatch. "
"Expected " + to_string(m_rpcSequence - 1) + " but got " + to_string(result["id"].asUInt()) + "."
);
if (result.isMember("error"))
{
if (_canFail)