diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-05 19:02:19 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-05 19:02:19 +0200 |
commit | 5922b6774e352e802ca9a347cc224cfebf1a6a7d (patch) | |
tree | e6de6f25e2bd81b9c89d22c46a49873c88e21b42 | |
parent | a651403e09ccc9ac0a3322e880d6543dd51a14bd (diff) | |
download | bitcoin-5922b6774e352e802ca9a347cc224cfebf1a6a7d.tar.xz |
Add assertion and cast before sending reject code
This gets rid of a warning. Add an assertion to make sure that the
reject code is in the correct range for the network protocol
(if it is outside the range it must be a bug)
-rw-r--r-- | src/main.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index f67f1fd0d7..4bf5883692 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1343,7 +1343,8 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state if (state.IsInvalid(nDoS)) { std::map<uint256, NodeId>::iterator it = mapBlockSource.find(pindex->GetBlockHash()); if (it != mapBlockSource.end() && State(it->second)) { - CBlockReject reject = {state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()}; + assert(state.GetRejectCode() < 0x100); + CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()}; State(it->second)->rejects.push_back(reject); if (nDoS > 0) Misbehaving(it->second, nDoS); |