File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,14 @@ class CScriptCompressor
8686 return ;
8787 }
8888 nSize -= nSpecialScripts;
89- script.resize (nSize);
90- s >> REF (CFlatData (script));
89+ if (nSize > MAX_SCRIPT_SIZE) {
90+ // Overly long script, replace with a short invalid one
91+ script << OP_RETURN;
92+ s.ignore (nSize);
93+ } else {
94+ script.resize (nSize);
95+ s >> REF (CFlatData (script));
96+ }
9197 }
9298};
9399
Original file line number Diff line number Diff line change @@ -406,6 +406,20 @@ class CAutoFile
406406 return (*this );
407407 }
408408
409+ CAutoFile& ignore (size_t nSize)
410+ {
411+ if (!file)
412+ throw std::ios_base::failure (" CAutoFile::ignore: file handle is NULL" );
413+ unsigned char data[4096 ];
414+ while (nSize > 0 ) {
415+ size_t nNow = std::min<size_t >(nSize, sizeof (data));
416+ if (fread (data, 1 , nNow, file) != nNow)
417+ throw std::ios_base::failure (feof (file) ? " CAutoFile::ignore: end of file" : " CAutoFile::read: fread failed" );
418+ nSize -= nNow;
419+ }
420+ return (*this );
421+ }
422+
409423 CAutoFile& write (const char * pch, size_t nSize)
410424 {
411425 if (!file)
You can’t perform that action at this time.
0 commit comments