What changed
Bitcoin v0.3.6 → v0.3.7
Release commit message: fixed segfault in bignum.h, additional security limits, refactoring -- version 0.3.7
Previous diff: v0.3.3 → v0.3.6. Next: v0.3.7 → v0.3.8.
- bignum.h modified · +12 −6
- build-unix.txt modified · +8 −18
- main.cpp modified · +2 −1
- makefile.unix modified · +4 −11
- script.cpp modified · +22 −12
- script.h modified · +0 −2
- serialize.h modified · +1 −1
- setup.nsi modified · +3 −3
bignum.h (modified)
1--- v0.3.6/bignum.h2+++ v0.3.7/bignum.h3@@ -401,8 +401,16 @@4 5 CBigNum& operator>>=(unsigned int shift)6 {7- // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number,8- // tested OK on 64-bit ubuntu 10.49+ // Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number10+ // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl11+ CBigNum a = 1;12+ a <<= shift;13+ if (BN_cmp(&a, this) > 0)14+ {15+ *this = 0;16+ return *this;17+ }18+19 if (!BN_rshift(this, this, shift))20 throw bignum_error("CBigNum:operator>>= : BN_rshift failed");21 return *this;22@@ -511,10 +519,8 @@23 24 inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)25 {26- CBigNum r;27- // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number28- if (!BN_rshift(&r, &a, shift))29- throw bignum_error("CBigNum:operator>> : BN_rshift failed");30+ CBigNum r = a;31+ r >>= shift;32 return r;33 }34
build-unix.txt (modified)
1--- v0.3.6/build-unix.txt2+++ v0.3.7/build-unix.txt3@@ -16,13 +16,12 @@4 sudo apt-get install libssl-dev5 sudo apt-get install libdb4.7-dev6 sudo apt-get install libdb4.7++-dev7-sudo apt-get install libboost-all-dev8+Boost 1.40+: sudo apt-get install libboost-all-dev9+or Boost 1.37: sudo apt-get install libboost1.37-dev10 11-We're now using wxWidgets 2.9, which uses UTF-8.12+If using Boost 1.37, append -mt to the boost libraries in the makefile.13 14-There isn't currently a debian package of wxWidgets we can use. The 2.815-packages for Karmic are UTF-16 unicode and won't work for us, and we've had16-trouble building 2.8 on 64-bit.17+We're now using wxWidgets 2.9, which uses UTF-8. Don't try 2.8, it won't work.18 19 You need to download wxWidgets from http://www.wxwidgets.org/downloads/20 and build it yourself. See the build instructions and configure parameters21@@ -34,11 +33,11 @@22 Boost MIT-like license23 24 Versions used in this release:25-GCC 4.4.326-OpenSSL 0.9.8k27+GCC 4.3.328+OpenSSL 0.9.8g29 wxWidgets 2.9.030 Berkeley DB 4.7.25.NC31-Boost 1.40.032+Boost 1.3733 34 35 Notes36@@ -55,19 +54,10 @@37 ---------38 cd /usr/local39 tar -xzvf wxWidgets-2.9.0.tar.gz40-cd /usr/local/wxWidgets-2.9.041+cd wxWidgets-2.9.042 mkdir buildgtk43 cd buildgtk44 ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic45-make46-sudo su47-make install48-ldconfig49-su <username>50-cd ..51-mkdir buildbase52-cd buildbase53-../configure --disable-gui --enable-debug --disable-shared --enable-monolithic54 make55 sudo su56 make install
main.cpp (modified)
1--- v0.3.6/main.cpp2+++ v0.3.7/main.cpp3@@ -3036,7 +3036,8 @@4 foreach(CWalletTx* pcoin, setCoins)5 for (int nOut = 0; nOut < pcoin->vout.size(); nOut++)6 if (pcoin->vout[nOut].IsMine())7- SignSignature(*pcoin, wtxNew, nIn++);8+ if (!SignSignature(*pcoin, wtxNew, nIn++))9+ return false;10 11 // Check that enough fee is included12 if (nFee < wtxNew.GetMinFee())
makefile.unix (modified)
1--- v0.3.6/makefile.unix2+++ v0.3.7/makefile.unix3@@ -4,13 +4,8 @@4 5 6 INCLUDEPATHS= \7- -I"/usr/include" \8 -I"/usr/local/include/wx-2.9" \9 -I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9"10-11-LIBPATHS= \12- -L"/usr/lib" \13- -L"/usr/local/lib"14 15 WXLIBS= \16 -Wl,-Bstatic \17@@ -18,6 +13,7 @@18 -Wl,-Bdynamic \19 -l gtk-x11-2.0 -l SM20 21+# for boost 1.37, add -mt to the boost libraries22 LIBS= \23 -Wl,-Bstatic \24 -l boost_system \25@@ -51,24 +47,21 @@26 all: bitcoin27 28 29-headers.h.gch: headers.h $(HEADERS)30- g++ -c $(CFLAGS) -DGUI -o $@ $<31-32-obj/%.o: %.cpp $(HEADERS) headers.h.gch33+obj/%.o: %.cpp $(HEADERS)34 g++ -c $(CFLAGS) -DGUI -o $@ $<35 36 cryptopp/obj/%.o: cryptopp/%.cpp37 g++ -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_SSE2 -o $@ $<38 39 bitcoin: $(OBJS) obj/ui.o obj/uibase.o40- g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)41+ g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)42 43 44 obj/nogui/%.o: %.cpp $(HEADERS)45 g++ -c $(CFLAGS) -o $@ $<46 47 bitcoind: $(OBJS:obj/%=obj/nogui/%)48- g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)49+ g++ $(CFLAGS) -o $@ $^ $(LIBS)50 51 52 clean:
script.cpp (modified)
1--- v0.3.6/script.cpp2+++ v0.3.7/script.cpp3@@ -42,20 +42,17 @@4 #define stacktop(i) (stack.at(stack.size()+(i)))5 #define altstacktop(i) (altstack.at(altstack.size()+(i)))6 7-bool EvalScript(const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType,8- vector<vector<unsigned char> >* pvStackRet)9+bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType)10 {11 CAutoBN_CTX pctx;12 CScript::const_iterator pc = script.begin();13 CScript::const_iterator pend = script.end();14 CScript::const_iterator pbegincodehash = script.begin();15 vector<bool> vfExec;16- vector<valtype> stack;17 vector<valtype> altstack;18- if (pvStackRet)19- pvStackRet->clear();20- if (script.size() > 20000)21- return false;22+ if (script.size() > 10000)23+ return false;24+ int nOpCount = 0;25 26 27 try28@@ -72,6 +69,8 @@29 if (!script.GetOp(pc, opcode, vchPushValue))30 return false;31 if (vchPushValue.size() > 5000)32+ return false;33+ if (opcode > OP_16 && nOpCount++ > 200)34 return false;35 36 if (fExec && opcode <= OP_PUSHDATA4)37@@ -828,9 +827,7 @@38 if (!vfExec.empty())39 return false;40 41- if (pvStackRet)42- *pvStackRet = stack;43- return (stack.empty() ? false : CastToBool(stack.back()));44+ return true;45 }46 47 #undef top48@@ -1114,6 +1111,19 @@49 }50 51 52+bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType)53+{54+ vector<vector<unsigned char> > stack;55+ if (!EvalScript(stack, scriptSig, txTo, nIn, nHashType))56+ return false;57+ if (!EvalScript(stack, scriptPubKey, txTo, nIn, nHashType))58+ return false;59+ if (stack.empty())60+ return false;61+ return CastToBool(stack.back());62+}63+64+65 bool SignSignature(const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType, CScript scriptPrereq)66 {67 assert(nIn < txTo.vin.size());68@@ -1132,7 +1142,7 @@69 70 // Test solution71 if (scriptPrereq.empty())72- if (!EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn))73+ if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, 0))74 return false;75 76 return true;77@@ -1150,7 +1160,7 @@78 if (txin.prevout.hash != txFrom.GetHash())79 return false;80 81- if (!EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn, nHashType))82+ if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, nHashType))83 return false;84 85 // Anytime a signature is successfully verified, it's proof the outpoint is spent,
script.h (modified)
1--- v0.3.6/script.h2+++ v0.3.7/script.h3@@ -657,8 +657,6 @@4 5 6 7-bool EvalScript(const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType=0,8- vector<vector<unsigned char> >* pvStackRet=NULL);9 uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);10 bool IsMine(const CScript& scriptPubKey);11 bool ExtractPubKey(const CScript& scriptPubKey, bool fMineOnly, vector<unsigned char>& vchPubKeyRet);
serialize.h (modified)
1--- v0.3.6/serialize.h2+++ v0.3.7/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 306;8+static const int VERSION = 307;9 static const char* pszSubVer = "";10 11
setup.nsi (modified)
1--- v0.3.6/setup.nsi2+++ v0.3.7/setup.nsi3@@ -7,7 +7,7 @@4 5 # General Symbol Definitions6 !define REGKEY "SOFTWARE\$(^Name)"7-!define VERSION 0.3.68+!define VERSION 0.3.79 !define COMPANY "Bitcoin project"10 !define URL http://www.bitcoin.org/11 12@@ -42,12 +42,12 @@13 !insertmacro MUI_LANGUAGE English14 15 # Installer attributes16-OutFile bitcoin-0.3.6-win32-setup.exe17+OutFile bitcoin-0.3.7-win32-setup.exe18 InstallDir $PROGRAMFILES\Bitcoin19 CRCCheck on20 XPStyle on21 ShowInstDetails show22-VIProductVersion 0.3.6.023+VIProductVersion 0.3.7.024 VIAddVersionKey ProductName Bitcoin25 VIAddVersionKey ProductVersion "${VERSION}"26 VIAddVersionKey CompanyName "${COMPANY}"
