Browse Source

Replace 520 constant with MAX_SCRIPT_ELEMENT_SIZE

miguelfreitas
Matt Corallo 12 years ago
parent
commit
192cc910ec
  1. 2
      src/main.cpp
  2. 4
      src/script.cpp
  3. 2
      src/script.h

2
src/main.cpp

@ -3588,7 +3588,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) @@ -3588,7 +3588,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Nodes must NEVER send a data item > 520 bytes (the max size for a script data object,
// and thus, the maximum size any matched object can have) in a filteradd message
if (vData.size() > 520)
if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE)
{
pfrom->Misbehaving(100);
} else {

4
src/script.cpp

@ -340,7 +340,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co @@ -340,7 +340,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
//
if (!script.GetOp(pc, opcode, vchPushValue))
return false;
if (vchPushValue.size() > 520)
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
return false;
if (opcode > OP_16 && ++nOpCount > 201)
return false;
@ -670,7 +670,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co @@ -670,7 +670,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
valtype& vch2 = stacktop(-1);
vch1.insert(vch1.end(), vch2.begin(), vch2.end());
popstack(stack);
if (stacktop(-1).size() > 520)
if (stacktop(-1).size() > MAX_SCRIPT_ELEMENT_SIZE)
return false;
}
break;

2
src/script.h

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
class CCoins;
class CTransaction;
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
/** Signature hash types/flags */
enum
{

Loading…
Cancel
Save