aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp13
-rw-r--r--src/init.cpp2
-rw-r--r--src/irc.cpp2
-rw-r--r--src/makefile.linux-mingw4
-rw-r--r--src/makefile.mingw4
-rw-r--r--src/net.cpp14
-rw-r--r--src/qt/qtipcserver.cpp2
-rw-r--r--src/qt/transactiondesc.cpp13
-rw-r--r--src/script.cpp24
-rw-r--r--src/util.h14
-rw-r--r--src/walletdb.h30
11 files changed, 41 insertions, 81 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 03d142f858..f9ea4be2c6 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -41,6 +41,11 @@ const Object emptyobj;
void ThreadRPCServer3(void* parg);
+static inline unsigned short GetDefaultRPCPort()
+{
+ return GetBoolArg("-testnet", false) ? 18332 : 8332;
+}
+
Object JSONRPCError(int code, const string& message)
{
Object error;
@@ -612,8 +617,6 @@ private:
void ThreadRPCServer(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadRPCServer(parg));
-
// Make this thread recognisable as the RPC listener
RenameThread("bitcoin-rpclist");
@@ -764,7 +767,7 @@ void ThreadRPCServer2(void* parg)
// Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets
const bool loopback = !mapArgs.count("-rpcallowip");
asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any();
- ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332));
+ ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", GetDefaultRPCPort()));
boost::system::error_code v6_only_error;
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service));
@@ -914,8 +917,6 @@ static CCriticalSection cs_THREAD_RPCHANDLER;
void ThreadRPCServer3(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadRPCServer3(parg));
-
// Make this thread recognisable as the RPC handler
RenameThread("bitcoin-rpchand");
@@ -1059,7 +1060,7 @@ Object CallRPC(const string& strMethod, const Array& params)
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);
- if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "8332")))
+ if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(GetDefaultRPCPort()))))
throw runtime_error("couldn't connect to server");
// HTTP basic authentication
diff --git a/src/init.cpp b/src/init.cpp
index 4df12af84c..7ed2613f76 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -272,7 +272,7 @@ std::string HelpMessage()
#endif
" -rpcuser=<user> " + _("Username for JSON-RPC connections") + "\n" +
" -rpcpassword=<pw> " + _("Password for JSON-RPC connections") + "\n" +
- " -rpcport=<port> " + _("Listen for JSON-RPC connections on <port> (default: 8332)") + "\n" +
+ " -rpcport=<port> " + _("Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)") + "\n" +
" -rpcallowip=<ip> " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
" -rpcconnect=<ip> " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
" -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
diff --git a/src/irc.cpp b/src/irc.cpp
index 6991e6ee7e..2f3fcc386e 100644
--- a/src/irc.cpp
+++ b/src/irc.cpp
@@ -188,8 +188,6 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
void ThreadIRCSeed(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadIRCSeed(parg));
-
// Make this thread recognisable as the IRC seeding thread
RenameThread("bitcoin-ircseed");
diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw
index 634a47b752..3709bb94d6 100644
--- a/src/makefile.linux-mingw
+++ b/src/makefile.linux-mingw
@@ -12,13 +12,13 @@ INCLUDEPATHS= \
-I"$(CURDIR)"/obj \
-I"$(DEPSDIR)/boost_1_50_0" \
-I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
- -I"$(DEPSDIR)/openssl-1.0.1b/include" \
+ -I"$(DEPSDIR)/openssl-1.0.1c/include" \
-I"$(DEPSDIR)"
LIBPATHS= \
-L"$(DEPSDIR)/boost_1_50_0/stage/lib" \
-L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
- -L"$(DEPSDIR)/openssl-1.0.1b"
+ -L"$(DEPSDIR)/openssl-1.0.1c"
LIBS= \
-l boost_system-mt-s \
diff --git a/src/makefile.mingw b/src/makefile.mingw
index fbd8c1b2dd..1a32f02bbf 100644
--- a/src/makefile.mingw
+++ b/src/makefile.mingw
@@ -8,12 +8,12 @@ USE_IPV6:=1
INCLUDEPATHS= \
-I"C:\boost-1.50.0-mgw" \
-I"C:\db-4.8.30.NC-mgw\build_unix" \
- -I"C:\openssl-1.0.1b-mgw\include"
+ -I"C:\openssl-1.0.1c-mgw\include"
LIBPATHS= \
-L"C:\boost-1.50.0-mgw\stage\lib" \
-L"C:\db-4.8.30.NC-mgw\build_unix" \
- -L"C:\openssl-1.0.1b-mgw"
+ -L"C:\openssl-1.0.1c-mgw"
LIBS= \
-l boost_system-mgw45-mt-s-1_50 \
diff --git a/src/net.cpp b/src/net.cpp
index 651f4a974c..5b0efd32e5 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -639,8 +639,6 @@ void CNode::copyStats(CNodeStats &stats)
void ThreadSocketHandler(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadSocketHandler(parg));
-
// Make this thread recognisable as the networking thread
RenameThread("bitcoin-net");
@@ -1000,8 +998,6 @@ void ThreadSocketHandler2(void* parg)
#ifdef USE_UPNP
void ThreadMapPort(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadMapPort(parg));
-
// Make this thread recognisable as the UPnP thread
RenameThread("bitcoin-UPnP");
@@ -1160,8 +1156,6 @@ static const char *strDNSSeed[][2] = {
void ThreadDNSAddressSeed(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadDNSAddressSeed(parg));
-
// Make this thread recognisable as the DNS seeding thread
RenameThread("bitcoin-dnsseed");
@@ -1333,8 +1327,6 @@ void ThreadDumpAddress2(void* parg)
void ThreadDumpAddress(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadDumpAddress(parg));
-
// Make this thread recognisable as the address dumping thread
RenameThread("bitcoin-adrdump");
@@ -1350,8 +1342,6 @@ void ThreadDumpAddress(void* parg)
void ThreadOpenConnections(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadOpenConnections(parg));
-
// Make this thread recognisable as the connection opening thread
RenameThread("bitcoin-opencon");
@@ -1513,8 +1503,6 @@ void ThreadOpenConnections2(void* parg)
void ThreadOpenAddedConnections(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadOpenAddedConnections(parg));
-
// Make this thread recognisable as the connection opening thread
RenameThread("bitcoin-opencon");
@@ -1646,8 +1634,6 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
void ThreadMessageHandler(void* parg)
{
- IMPLEMENT_RANDOMIZE_STACK(ThreadMessageHandler(parg));
-
// Make this thread recognisable as the message handling thread
RenameThread("bitcoin-msghand");
diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp
index ec2d56b9e3..74f44fac57 100644
--- a/src/qt/qtipcserver.cpp
+++ b/src/qt/qtipcserver.cpp
@@ -74,8 +74,6 @@ void ipcScanRelay(int argc, char *argv[])
static void ipcThread(void* pArg)
{
- IMPLEMENT_RANDOMIZE_STACK(ipcThread(pArg));
-
// Make this thread recognisable as the GUI-IPC thread
RenameThread("bitcoin-gui-ipc");
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 3e7eca59ca..efc77e190e 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -64,11 +64,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
}
- else if (!wtx.mapValue["from"].empty())
+ else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())
{
// Online transaction
- if (!wtx.mapValue["from"].empty())
- strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
+ strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
}
else
{
@@ -104,7 +103,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
//
// To
//
- if (!wtx.mapValue["to"].empty())
+ if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty())
{
// Online transaction
std::string strAddress = wtx.mapValue["to"];
@@ -160,7 +159,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
if (wallet->IsMine(txout))
continue;
- if (wtx.mapValue["to"].empty())
+ if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty())
{
// Offline transaction
CTxDestination address;
@@ -209,9 +208,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
//
// Message
//
- if (!wtx.mapValue["message"].empty())
+ if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty())
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "<br>";
- if (!wtx.mapValue["comment"].empty())
+ if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + wtx.GetHash().ToString().c_str() + "<br>";
diff --git a/src/script.cpp b/src/script.cpp
index c34fbec82d..4357a9a1b3 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -54,12 +54,29 @@ bool CastToBool(const valtype& vch)
return false;
}
+//
+// WARNING: This does not work as expected for signed integers; the sign-bit
+// is left in place as the integer is zero-extended. The correct behavior
+// would be to move the most significant bit of the last byte during the
+// resize process. MakeSameSize() is currently only used by the disabled
+// opcodes OP_AND, OP_OR, and OP_XOR.
+//
void MakeSameSize(valtype& vch1, valtype& vch2)
{
// Lengthen the shorter one
if (vch1.size() < vch2.size())
+ // PATCH:
+ // +unsigned char msb = vch1[vch1.size()-1];
+ // +vch1[vch1.size()-1] &= 0x7f;
+ // vch1.resize(vch2.size(), 0);
+ // +vch1[vch1.size()-1] = msb;
vch1.resize(vch2.size(), 0);
if (vch2.size() < vch1.size())
+ // PATCH:
+ // +unsigned char msb = vch2[vch2.size()-1];
+ // +vch2[vch2.size()-1] &= 0x7f;
+ // vch2.resize(vch1.size(), 0);
+ // +vch2[vch2.size()-1] = msb;
vch2.resize(vch1.size(), 0);
}
@@ -663,6 +680,11 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
}
break;
+ //
+ // WARNING: These disabled opcodes exhibit unexpected behavior
+ // when used on signed integers due to a bug in MakeSameSize()
+ // [see definition of MakeSameSize() above].
+ //
case OP_AND:
case OP_OR:
case OP_XOR:
@@ -672,7 +694,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
return false;
valtype& vch1 = stacktop(-2);
valtype& vch2 = stacktop(-1);
- MakeSameSize(vch1, vch2);
+ MakeSameSize(vch1, vch2); // <-- NOT SAFE FOR SIGNED VALUES
if (opcode == OP_AND)
{
for (unsigned int i = 0; i < vch1.size(); i++)
diff --git a/src/util.h b/src/util.h
index 54b53582b5..745c3d786a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -396,20 +396,6 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue);
-// Randomize the stack to help protect against buffer overrun exploits
-#define IMPLEMENT_RANDOMIZE_STACK(ThreadFn) \
- { \
- static char nLoops; \
- if (nLoops <= 0) \
- nLoops = GetRand(20) + 1; \
- if (nLoops-- > 1) \
- { \
- ThreadFn; \
- return; \
- } \
- }
-
-
template<typename T1>
inline uint256 Hash(const T1 pbegin, const T1 pend)
{
diff --git a/src/walletdb.h b/src/walletdb.h
index d339d4c3f1..f078481811 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -33,21 +33,10 @@ private:
CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&);
public:
- bool ReadName(const std::string& strAddress, std::string& strName)
- {
- strName = "";
- return Read(std::make_pair(std::string("name"), strAddress), strName);
- }
-
bool WriteName(const std::string& strAddress, const std::string& strName);
bool EraseName(const std::string& strAddress);
- bool ReadTx(uint256 hash, CWalletTx& wtx)
- {
- return Read(std::make_pair(std::string("tx"), hash), wtx);
- }
-
bool WriteTx(uint256 hash, const CWalletTx& wtx)
{
nWalletDBUpdated++;
@@ -60,12 +49,6 @@ public:
return Erase(std::make_pair(std::string("tx"), hash));
}
- bool ReadKey(const CPubKey& vchPubKey, CPrivKey& vchPrivKey)
- {
- vchPrivKey.clear();
- return Read(std::make_pair(std::string("key"), vchPubKey.Raw()), vchPrivKey);
- }
-
bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey)
{
nWalletDBUpdated++;
@@ -91,13 +74,6 @@ public:
return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true);
}
- // Support for BIP 0013 : see https://en.bitcoin.it/wiki/BIP_0013
- bool ReadCScript(const uint160 &hash, CScript& redeemScript)
- {
- redeemScript.clear();
- return Read(std::make_pair(std::string("cscript"), hash), redeemScript);
- }
-
bool WriteCScript(const uint160& hash, const CScript& redeemScript)
{
nWalletDBUpdated++;
@@ -121,12 +97,6 @@ public:
return Write(std::string("orderposnext"), nOrderPosNext);
}
- bool ReadDefaultKey(std::vector<unsigned char>& vchPubKey)
- {
- vchPubKey.clear();
- return Read(std::string("defaultkey"), vchPubKey);
- }
-
bool WriteDefaultKey(const CPubKey& vchPubKey)
{
nWalletDBUpdated++;