Skip to content

Commit 5922b67

Browse files
committed
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)
1 parent a651403 commit 5922b67

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,8 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
13431343
if (state.IsInvalid(nDoS)) {
13441344
std::map<uint256, NodeId>::iterator it = mapBlockSource.find(pindex->GetBlockHash());
13451345
if (it != mapBlockSource.end() && State(it->second)) {
1346-
CBlockReject reject = {state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()};
1346+
assert(state.GetRejectCode() < 0x100);
1347+
CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()};
13471348
State(it->second)->rejects.push_back(reject);
13481349
if (nDoS > 0)
13491350
Misbehaving(it->second, nDoS);

0 commit comments

Comments
 (0)