@@ -1327,7 +1327,7 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
1327
1327
if (state.IsInvalid (nDoS)) {
1328
1328
std::map<uint256, NodeId>::iterator it = mapBlockSource.find (pindex->GetBlockHash ());
1329
1329
if (it != mapBlockSource.end () && State (it->second )) {
1330
- CBlockReject reject = {state.GetRejectCode (), state.GetRejectReason (), pindex->GetBlockHash ()};
1330
+ CBlockReject reject = {state.GetRejectCode (), state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , pindex->GetBlockHash ()};
1331
1331
State (it->second )->rejects .push_back (reject);
1332
1332
if (nDoS > 0 )
1333
1333
Misbehaving (it->second , nDoS);
@@ -1357,10 +1357,11 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
1357
1357
inputs.ModifyCoins (tx.GetHash ())->FromTx (tx, nHeight);
1358
1358
}
1359
1359
1360
- bool CScriptCheck::operator ()() const {
1360
+ bool CScriptCheck::operator ()() {
1361
1361
const CScript &scriptSig = ptxTo->vin [nIn].scriptSig ;
1362
- if (!VerifyScript (scriptSig, scriptPubKey, nFlags, CachingSignatureChecker (*ptxTo, nIn, cacheStore)))
1363
- return error (" CScriptCheck() : %s:%d VerifySignature failed" , ptxTo->GetHash ().ToString (), nIn);
1362
+ if (!VerifyScript (scriptSig, scriptPubKey, nFlags, CachingSignatureChecker (*ptxTo, nIn, cacheStore), &error)) {
1363
+ return ::error (" CScriptCheck() : %s:%d VerifySignature failed: %s" , ptxTo->GetHash ().ToString (), nIn, ScriptErrorString (error));
1364
+ }
1364
1365
return true ;
1365
1366
}
1366
1367
@@ -1448,7 +1449,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1448
1449
CScriptCheck check (*coins, tx, i,
1449
1450
flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, cacheStore);
1450
1451
if (check ())
1451
- return state.Invalid (false , REJECT_NONSTANDARD, " non-mandatory-script-verify-flag" );
1452
+ return state.Invalid (false , REJECT_NONSTANDARD, strprintf ( " non-mandatory-script-verify-flag (%s) " , ScriptErrorString (check. GetScriptError ())) );
1452
1453
}
1453
1454
// Failures of other flags indicate a transaction that is
1454
1455
// invalid in new blocks, e.g. a invalid P2SH. We DoS ban
@@ -1457,7 +1458,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1457
1458
// as to the correct behavior - we may want to continue
1458
1459
// peering with non-upgraded nodes even after a soft-fork
1459
1460
// super-majority vote has passed.
1460
- return state.DoS (100 ,false , REJECT_INVALID, " mandatory-script-verify-flag-failed" );
1461
+ return state.DoS (100 ,false , REJECT_INVALID, strprintf ( " mandatory-script-verify-flag-failed (%s) " , ScriptErrorString (check. GetScriptError ())) );
1461
1462
}
1462
1463
}
1463
1464
}
@@ -3975,7 +3976,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
3975
3976
pfrom->id , pfrom->cleanSubVer ,
3976
3977
state.GetRejectReason ());
3977
3978
pfrom->PushMessage (" reject" , strCommand, state.GetRejectCode (),
3978
- state.GetRejectReason (), inv.hash );
3979
+ state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , inv.hash );
3979
3980
if (nDoS > 0 )
3980
3981
Misbehaving (pfrom->GetId (), nDoS);
3981
3982
}
@@ -4049,7 +4050,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4049
4050
int nDoS;
4050
4051
if (state.IsInvalid (nDoS)) {
4051
4052
pfrom->PushMessage (" reject" , strCommand, state.GetRejectCode (),
4052
- state.GetRejectReason (), inv.hash );
4053
+ state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , inv.hash );
4053
4054
if (nDoS > 0 ) {
4054
4055
LOCK (cs_main);
4055
4056
Misbehaving (pfrom->GetId (), nDoS);
@@ -4256,7 +4257,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4256
4257
if (fDebug ) {
4257
4258
try {
4258
4259
string strMsg; unsigned char ccode; string strReason;
4259
- vRecv >> LIMITED_STRING (strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING (strReason, 111 );
4260
+ vRecv >> LIMITED_STRING (strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING (strReason, MAX_REJECT_MESSAGE_LENGTH );
4260
4261
4261
4262
ostringstream ss;
4262
4263
ss << strMsg << " code " << itostr (ccode) << " : " << strReason;
0 commit comments