Merge pull request #5907 from ethereum/rpcsession-check-id

Check message identifier in RPCSession
This commit is contained in:
chriseth 2019-01-31 13:36:37 +01:00 committed by GitHub
commit ddab3f06a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,7 +324,15 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const&
Json::Value result;
string errorMsg;
if (!jsonParseStrict(reply, result, &errorMsg))
BOOST_REQUIRE_MESSAGE(false, errorMsg);
BOOST_FAIL("Failed to parse JSON-RPC response: " + 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"))
{