@@ -1334,7 +1334,7 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
1334
1334
if (state.IsInvalid (nDoS)) {
1335
1335
std::map<uint256, NodeId>::iterator it = mapBlockSource.find (pindex->GetBlockHash ());
1336
1336
if (it != mapBlockSource.end () && State (it->second )) {
1337
- CBlockReject reject = {state.GetRejectCode (), state.GetRejectReason (), pindex->GetBlockHash ()};
1337
+ CBlockReject reject = {state.GetRejectCode (), state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , pindex->GetBlockHash ()};
1338
1338
State (it->second )->rejects .push_back (reject);
1339
1339
if (nDoS > 0 )
1340
1340
Misbehaving (it->second , nDoS);
@@ -1364,10 +1364,11 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
1364
1364
inputs.ModifyCoins (tx.GetHash ())->FromTx (tx, nHeight);
1365
1365
}
1366
1366
1367
- bool CScriptCheck::operator ()() const {
1367
+ bool CScriptCheck::operator ()() {
1368
1368
const CScript &scriptSig = ptxTo->vin [nIn].scriptSig ;
1369
- if (!VerifyScript (scriptSig, scriptPubKey, nFlags, CachingSignatureChecker (*ptxTo, nIn, cacheStore)))
1370
- return error (" CScriptCheck() : %s:%d VerifySignature failed" , ptxTo->GetHash ().ToString (), nIn);
1369
+ if (!VerifyScript (scriptSig, scriptPubKey, nFlags, CachingSignatureChecker (*ptxTo, nIn, cacheStore), &error)) {
1370
+ return ::error (" CScriptCheck() : %s:%d VerifySignature failed: %s" , ptxTo->GetHash ().ToString (), nIn, ScriptErrorString (error));
1371
+ }
1371
1372
return true ;
1372
1373
}
1373
1374
@@ -1455,7 +1456,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1455
1456
CScriptCheck check (*coins, tx, i,
1456
1457
flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, cacheStore);
1457
1458
if (check ())
1458
- return state.Invalid (false , REJECT_NONSTANDARD, " non-mandatory-script-verify-flag" );
1459
+ return state.Invalid (false , REJECT_NONSTANDARD, strprintf ( " non-mandatory-script-verify-flag (%s) " , ScriptErrorString (check. GetScriptError ())) );
1459
1460
}
1460
1461
// Failures of other flags indicate a transaction that is
1461
1462
// invalid in new blocks, e.g. a invalid P2SH. We DoS ban
@@ -1464,7 +1465,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1464
1465
// as to the correct behavior - we may want to continue
1465
1466
// peering with non-upgraded nodes even after a soft-fork
1466
1467
// super-majority vote has passed.
1467
- return state.DoS (100 ,false , REJECT_INVALID, " mandatory-script-verify-flag-failed" );
1468
+ return state.DoS (100 ,false , REJECT_INVALID, strprintf ( " mandatory-script-verify-flag-failed (%s) " , ScriptErrorString (check. GetScriptError ())) );
1468
1469
}
1469
1470
}
1470
1471
}
@@ -3990,7 +3991,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
3990
3991
pfrom->id , pfrom->cleanSubVer ,
3991
3992
state.GetRejectReason ());
3992
3993
pfrom->PushMessage (" reject" , strCommand, state.GetRejectCode (),
3993
- state.GetRejectReason (), inv.hash );
3994
+ state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , inv.hash );
3994
3995
if (nDoS > 0 )
3995
3996
Misbehaving (pfrom->GetId (), nDoS);
3996
3997
}
@@ -4064,7 +4065,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4064
4065
int nDoS;
4065
4066
if (state.IsInvalid (nDoS)) {
4066
4067
pfrom->PushMessage (" reject" , strCommand, state.GetRejectCode (),
4067
- state.GetRejectReason (), inv.hash );
4068
+ state.GetRejectReason (). substr ( 0 , MAX_REJECT_MESSAGE_LENGTH) , inv.hash );
4068
4069
if (nDoS > 0 ) {
4069
4070
LOCK (cs_main);
4070
4071
Misbehaving (pfrom->GetId (), nDoS);
@@ -4271,7 +4272,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4271
4272
if (fDebug ) {
4272
4273
try {
4273
4274
string strMsg; unsigned char ccode; string strReason;
4274
- vRecv >> LIMITED_STRING (strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING (strReason, 111 );
4275
+ vRecv >> LIMITED_STRING (strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING (strReason, MAX_REJECT_MESSAGE_LENGTH );
4275
4276
4276
4277
ostringstream ss;
4277
4278
ss << strMsg << " code " << itostr (ccode) << " : " << strReason;
0 commit comments