X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fmain.h;h=74bbe2940ed7a18d6034ba6745ab6c43075d2c84;hb=3703150d56ff6ee557ab330e55637c9c23835902;hp=f55f189e4c26a9e923de7bc02b0e46f95fce8e1b;hpb=a93ab877877925c60b2dbf56bdde8aa46b6b7391;p=novacoin.git diff --git a/src/main.h b/src/main.h index f55f189..74bbe29 100644 --- a/src/main.h +++ b/src/main.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_MAIN_H #define BITCOIN_MAIN_H @@ -513,7 +513,7 @@ public: bool IsStandard() const { BOOST_FOREACH(const CTxIn& txin, vin) - if (!txin.scriptSig.IsPushOnly()) + if (txin.scriptSig.size() > 200 || !txin.scriptSig.IsPushOnly()) return error("nonstandard txin: %s", txin.scriptSig.ToString().c_str()); BOOST_FOREACH(const CTxOut& txout, vout) if (!::IsStandard(txout.scriptPubKey)) @@ -607,7 +607,13 @@ public: // Read transaction if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) return error("CTransaction::ReadFromDisk() : fseek failed"); - filein >> *this; + + try { + filein >> *this; + } + catch (std::exception &e) { + return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); + } // Return file pointer if (pfileRet) @@ -971,9 +977,10 @@ public: fileout << FLATDATA(pchMessageStart) << nSize; // Write block - nBlockPosRet = ftell(fileout); - if (nBlockPosRet == -1) + long fileOutPos = ftell(fileout); + if (fileOutPos < 0) return error("CBlock::WriteToDisk() : ftell failed"); + nBlockPosRet = fileOutPos; fileout << *this; // Flush stdio buffers and commit to disk before returning @@ -1002,7 +1009,12 @@ public: filein.nType |= SER_BLOCKHEADERONLY; // Read block - filein >> *this; + try { + filein >> *this; + } + catch (std::exception &e) { + return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); + } // Check the header if (!CheckProofOfWork(GetHash(), nBits))