aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bitcoin-qt.pro8
-rw-r--r--contrib/gitian-descriptors/README2
-rw-r--r--contrib/gitian-descriptors/deps-win32.yml10
-rw-r--r--contrib/gitian-descriptors/gitian-win32.yml8
-rw-r--r--doc/build-msw.txt12
-rw-r--r--doc/build-unix.txt6
-rw-r--r--doc/release-process.txt4
-rw-r--r--src/bignum.h2
-rw-r--r--src/bitcoinrpc.cpp13
-rw-r--r--src/init.cpp17
-rw-r--r--src/irc.cpp2
-rw-r--r--src/makefile.linux-mingw6
-rw-r--r--src/makefile.mingw6
-rw-r--r--src/makefile.osx2
-rw-r--r--src/makefile.unix2
-rw-r--r--src/net.cpp14
-rw-r--r--src/qt/qtipcserver.cpp2
-rw-r--r--src/script.cpp24
-rw-r--r--src/sync.h2
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp21
-rw-r--r--src/util.h74
-rw-r--r--src/walletdb.h30
23 files changed, 145 insertions, 124 deletions
diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro
index c6ddc98ff4..427c773e04 100644
--- a/bitcoin-qt.pro
+++ b/bitcoin-qt.pro
@@ -4,6 +4,7 @@ VERSION = 0.7.0
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
+CONFIG += thread
# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
@@ -100,7 +101,7 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
DEFINES += HAVE_BUILD_INFO
}
-QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector
+QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter -Wstack-protector
# Input
DEPENDPATH += src src/json src/qt
@@ -336,7 +337,7 @@ windows:!contains(MINGW_THREAD_BUGFIX, 0) {
QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}
-!windows:!mac {
+!windows:!macx {
DEFINES += LINUX
LIBS += -lrt
}
@@ -347,6 +348,9 @@ macx:LIBS += -framework Foundation -framework ApplicationServices -framework App
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/bitcoin.icns
macx:TARGET = "Bitcoin-Qt"
+macx:QMAKE_CFLAGS_THREAD += -pthread
+macx:QMAKE_LFLAGS_THREAD += -pthread
+macx:QMAKE_CXXFLAGS_THREAD += -pthread
# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
diff --git a/contrib/gitian-descriptors/README b/contrib/gitian-descriptors/README
index ad5a366d20..1d3910b994 100644
--- a/contrib/gitian-descriptors/README
+++ b/contrib/gitian-descriptors/README
@@ -27,7 +27,7 @@ Once you've got the right hardware and software:
wget 'http://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.bz2'
# Inputs for Win32: (Linux has packages for these)
wget 'https://downloads.sourceforge.net/project/boost/boost/1.50.0/boost_1_50_0.tar.bz2'
- wget 'http://www.openssl.org/source/openssl-1.0.1b.tar.gz'
+ wget 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz'
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
wget 'https://downloads.sourceforge.net/project/libpng/zlib/1.2.6/zlib-1.2.6.tar.gz'
wget 'https://downloads.sourceforge.net/project/libpng/libpng15/older-releases/1.5.9/libpng-1.5.9.tar.gz'
diff --git a/contrib/gitian-descriptors/deps-win32.yml b/contrib/gitian-descriptors/deps-win32.yml
index df1e3de358..106bd06a9b 100644
--- a/contrib/gitian-descriptors/deps-win32.yml
+++ b/contrib/gitian-descriptors/deps-win32.yml
@@ -4,7 +4,7 @@ suites:
- "lucid"
architectures:
- "i386"
-packages:
+packages:
- "mingw32"
- "git-core"
- "zip"
@@ -13,7 +13,7 @@ packages:
reference_datetime: "2011-01-30 00:00:00"
remotes: []
files:
-- "openssl-1.0.1b.tar.gz"
+- "openssl-1.0.1c.tar.gz"
- "db-4.8.30.NC.tar.gz"
- "miniupnpc-1.6.tar.gz"
- "zlib-1.2.6.tar.gz"
@@ -25,8 +25,8 @@ script: |
export FAKETIME=$REFERENCE_DATETIME
export TZ=UTC
#
- tar xzf openssl-1.0.1b.tar.gz
- cd openssl-1.0.1b
+ tar xzf openssl-1.0.1c.tar.gz
+ cd openssl-1.0.1c
./Configure --cross-compile-prefix=i586-mingw32msvc- mingw
make
cd ..
@@ -62,7 +62,7 @@ script: |
make $MAKEOPTS
cd ..
#
- zip -r $OUTDIR/bitcoin-deps-0.0.4.zip \
+ zip -r $OUTDIR/bitcoin-deps-0.0.5.zip \
$(ls qrencode-*/{qrencode.h,.libs/libqrencode.{,l}a} | sort) \
$(ls db-*/build_unix/{libdb_cxx.a,db.h,db_cxx.h,libdb.a,.libs/libdb_cxx-?.?.a} | sort) \
$(find openssl-* -name '*.a' -o -name '*.h' | sort) \
diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml
index fa6636f528..c5979614d3 100644
--- a/contrib/gitian-descriptors/gitian-win32.yml
+++ b/contrib/gitian-descriptors/gitian-win32.yml
@@ -4,7 +4,7 @@ suites:
- "lucid"
architectures:
- "i386"
-packages:
+packages:
- "mingw32"
- "git-core"
- "unzip"
@@ -17,7 +17,7 @@ remotes:
files:
- "qt-win32-4.8.2-gitian-r1.zip"
- "boost-win32-1.50.0-gitian2.zip"
-- "bitcoin-deps-0.0.4.zip"
+- "bitcoin-deps-0.0.5.zip"
script: |
#
mkdir $HOME/qt
@@ -39,7 +39,7 @@ script: |
mv include/boost .
cd ..
#
- unzip bitcoin-deps-0.0.4.zip
+ unzip bitcoin-deps-0.0.5.zip
#
find -type f | xargs touch --date="$REFERENCE_DATETIME"
#
@@ -51,7 +51,7 @@ script: |
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
export FAKETIME=$REFERENCE_DATETIME
export TZ=UTC
- $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_50_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_50_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1b OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1b/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin QMAKE_LFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1
+ $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_50_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_50_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1c OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1c/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin QMAKE_LFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1
make $MAKEOPTS
cp release/bitcoin-qt.exe $OUTDIR/
#
diff --git a/doc/build-msw.txt b/doc/build-msw.txt
index c887a7be8c..3e64813b38 100644
--- a/doc/build-msw.txt
+++ b/doc/build-msw.txt
@@ -24,9 +24,9 @@ Dependencies
Libraries you need to download separately and build:
default path download
-OpenSSL \openssl-1.0.1b-mgw http://www.openssl.org/source/
+OpenSSL \openssl-1.0.1c-mgw http://www.openssl.org/source/
Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html
-Boost \boost-1.47.0-mgw http://www.boost.org/users/download/
+Boost \boost-1.50.0-mgw http://www.boost.org/users/download/
miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/
Their licenses:
@@ -36,9 +36,9 @@ Boost MIT-like license
miniupnpc New (3-clause) BSD license
Versions used in this release:
-OpenSSL 1.0.1b
+OpenSSL 1.0.1c
Berkeley DB 4.8.30.NC
-Boost 1.47.0
+Boost 1.50.0
miniupnpc 1.6
@@ -48,7 +48,7 @@ MSYS shell:
un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'
-cd /c/openssl-1.0.1b-mgw
+cd /c/openssl-1.0.1c-mgw
./config
make
@@ -63,7 +63,7 @@ Boost
-----
DOS prompt:
downloaded boost jam 3.1.18
-cd \boost-1.47.0-mgw
+cd \boost-1.50.0-mgw
bjam toolset=gcc --build-type=complete stage
MiniUPnPc
diff --git a/doc/build-unix.txt b/doc/build-unix.txt
index b02a20a760..2e0b53cf77 100644
--- a/doc/build-unix.txt
+++ b/doc/build-unix.txt
@@ -47,7 +47,7 @@ Licenses of statically linked libraries:
Versions used in this release:
GCC 4.3.3
- OpenSSL 0.9.8g
+ OpenSSL 1.0.1c
Berkeley DB 4.8.30.NC
Boost 1.37
miniupnpc 1.6
@@ -55,7 +55,7 @@ Versions used in this release:
Dependency Build Instructions: Ubuntu & Debian
----------------------------------------------
Build requirements:
- sudo apt-get install build-essential
+ sudo apt-get install build-essential
sudo apt-get install libssl-dev
for Ubuntu 12.04:
@@ -68,7 +68,7 @@ for Ubuntu 12.04:
but using these will break binary wallet compatibility, and is not recommended.
for other Ubuntu & Debian:
- sudo apt-get install libdb4.8-dev
+ sudo apt-get install libdb4.8-dev
sudo apt-get install libdb4.8++-dev
sudo apt-get install libboost1.37-dev
(If using Boost 1.37, append -mt to the boost libraries in the makefile)
diff --git a/doc/release-process.txt b/doc/release-process.txt
index c74bc3da13..075fb01db7 100644
--- a/doc/release-process.txt
+++ b/doc/release-process.txt
@@ -24,7 +24,7 @@
* Fetch and build inputs: (first time, or when dependency versions change)
mkdir -p inputs; cd inputs/
wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.6.tar.gz' -O miniupnpc-1.6.tar.gz
- wget 'http://www.openssl.org/source/openssl-1.0.1b.tar.gz'
+ wget 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz'
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
wget 'http://zlib.net/zlib-1.2.6.tar.gz'
wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz'
@@ -37,7 +37,7 @@
./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win32.yml
mv build/out/qt-win32-4.8.2-gitian-r1.zip inputs/
./bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-win32.yml
- mv build/out/bitcoin-deps-0.0.3.zip inputs/
+ mv build/out/bitcoin-deps-0.0.5.zip inputs/
* Build bitcoind and bitcoin-qt on Linux32, Linux64, and Win32:
./bin/gbuild --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian.yml
diff --git a/src/bignum.h b/src/bignum.h
index 9fea3f70fb..96b1b2e6ae 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -305,7 +305,7 @@ public:
psz++;
// hex string to bignum
- static signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
*this = 0;
while (isxdigit(*psz))
{
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 dc425da644..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" +
@@ -722,7 +722,8 @@ bool AppInit2()
if (mapArgs.count("-loadblock"))
{
- uiInterface.InitMessage(_("Importing blocks..."));
+ uiInterface.InitMessage(_("Importing blockchain data file."));
+
BOOST_FOREACH(string strFile, mapMultiArgs["-loadblock"])
{
FILE *file = fopen(strFile.c_str(), "rb");
@@ -731,6 +732,18 @@ bool AppInit2()
}
}
+ filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
+ if (filesystem::exists(pathBootstrap)) {
+ uiInterface.InitMessage(_("Importing bootstrap blockchain data file."));
+
+ FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
+ if (file) {
+ filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
+ LoadExternalBlockFile(file);
+ RenameOver(pathBootstrap, pathBootstrapOld);
+ }
+ }
+
// ********************************************************* Step 9: load peers
uiInterface.InitMessage(_("Loading addresses..."));
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 2804f14055..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 \
@@ -32,7 +32,7 @@ LIBS= \
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
-CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-O2 -w -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
diff --git a/src/makefile.mingw b/src/makefile.mingw
index 5cb2c84f4d..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 \
@@ -27,7 +27,7 @@ LIBS= \
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
-CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
diff --git a/src/makefile.osx b/src/makefile.osx
index 359739bd5e..a0de217c01 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -66,7 +66,7 @@ CFLAGS = -g
endif
# ppc doesn't work because we don't support big-endian
-CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
+CFLAGS += -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
OBJS= \
diff --git a/src/makefile.unix b/src/makefile.unix
index a41b57b4fc..b73ce2833b 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -93,7 +93,7 @@ DEBUGFLAGS=-g
# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
-xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
+xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
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/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/sync.h b/src/sync.h
index 98640e6eab..e80efbe001 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -31,7 +31,7 @@ void static inline LeaveCritical() {}
void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
#endif
-/** Wrapper around boost::interprocess::scoped_lock */
+/** Wrapper around boost::unique_lock<Mutex> */
template<typename Mutex>
class CMutexLock
{
diff --git a/src/uint256.h b/src/uint256.h
index fc5ed26592..abd0b71e6f 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -306,7 +306,7 @@ public:
psz += 2;
// hex string to uint
- static unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static const unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
const char* pbegin = psz;
while (phexdigit[(unsigned char)*psz] || *psz == '0')
psz++;
diff --git a/src/util.cpp b/src/util.cpp
index d1270348e0..a8bd8228e5 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -274,7 +274,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
return ret;
}
-string vstrprintf(const std::string &format, va_list ap)
+string vstrprintf(const char *format, va_list ap)
{
char buffer[50000];
char* p = buffer;
@@ -284,7 +284,11 @@ string vstrprintf(const std::string &format, va_list ap)
{
va_list arg_ptr;
va_copy(arg_ptr, ap);
- ret = _vsnprintf(p, limit, format.c_str(), arg_ptr);
+#ifdef WIN32
+ ret = _vsnprintf(p, limit, format, arg_ptr);
+#else
+ ret = vsnprintf(p, limit, format, arg_ptr);
+#endif
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
@@ -301,7 +305,7 @@ string vstrprintf(const std::string &format, va_list ap)
return str;
}
-string real_strprintf(const std::string &format, int dummy, ...)
+string real_strprintf(const char *format, int dummy, ...)
{
va_list arg_ptr;
va_start(arg_ptr, dummy);
@@ -310,6 +314,15 @@ string real_strprintf(const std::string &format, int dummy, ...)
return str;
}
+string real_strprintf(const std::string &format, int dummy, ...)
+{
+ va_list arg_ptr;
+ va_start(arg_ptr, dummy);
+ string str = vstrprintf(format.c_str(), arg_ptr);
+ va_end(arg_ptr);
+ return str;
+}
+
bool error(const char *format, ...)
{
va_list arg_ptr;
@@ -411,7 +424,7 @@ bool ParseMoney(const char* pszIn, int64& nRet)
}
-static signed char phexdigit[256] =
+static const signed char phexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
diff --git a/src/util.h b/src/util.h
index 2409ccb79c..745c3d786a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -41,7 +41,6 @@ static const int64 CENT = 1000000;
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
-#define printf OutputDebugStringF
#ifndef PRI64d
#if defined(_MSC_VER) || defined(__MSVCRT__)
@@ -55,6 +54,17 @@ static const int64 CENT = 1000000;
#endif
#endif
+/* Format characters for (s)size_t and ptrdiff_t */
+#if defined(_MSC_VER) || defined(__MSVCRT__)
+ #define PRIszx "%Ix"
+ #define PRIszu "%Iu"
+ #define PRIszd "%Id"
+#else
+ #define PRIszx "%zx"
+ #define PRIszu "%zu"
+ #define PRIszd "%zd"
+#endif
+
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
@@ -80,11 +90,7 @@ T* alignup(T* p)
#define S_IRUSR 0400
#define S_IWUSR 0200
#endif
-#define unlink _unlink
#else
-#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
-#define strlwr(psz) to_lower(psz)
-#define _strlwr(psz) to_lower(psz)
#define MAX_PATH 1024
inline void Sleep(int64 n)
{
@@ -94,6 +100,15 @@ inline void Sleep(int64 n)
}
#endif
+/* This GNU C extension enables the compiler to check the format string against the parameters provided.
+ * X is the number of the "format string" parameter, and Y is the number of the first variadic parameter.
+ * Parameters count from 1.
+ */
+#ifdef __GNUC__
+#define ATTR_WARN_PRINTF(X,Y) __attribute__((format(printf,X,Y)))
+#else
+#define ATTR_WARN_PRINTF(X,Y)
+#endif
@@ -121,16 +136,31 @@ extern bool fReopenDebugLog;
void RandAddSeed();
void RandAddSeedPerfmon();
-int OutputDebugStringF(const char* pszFormat, ...);
-int my_snprintf(char* buffer, size_t limit, const char* format, ...);
+int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
-/* It is not allowed to use va_start with a pass-by-reference argument.
- (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
- macro to keep similar semantics.
+/*
+ Rationale for the real_strprintf / strprintf construction:
+ It is not allowed to use va_start with a pass-by-reference argument.
+ (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
+ macro to keep similar semantics.
*/
+
+/** Overload strprintf for char*, so that GCC format type warnings can be given */
+std::string ATTR_WARN_PRINTF(1,3) real_strprintf(const char *format, int dummy, ...);
+/** Overload strprintf for std::string, to be able to use it with _ (translation).
+ * This will not support GCC format type warnings (-Wformat) so be careful.
+ */
std::string real_strprintf(const std::string &format, int dummy, ...);
#define strprintf(format, ...) real_strprintf(format, 0, __VA_ARGS__)
-std::string vstrprintf(const std::string &format, va_list ap);
+std::string vstrprintf(const char *format, va_list ap);
+
+/* Redefine printf so that it directs output to debug.log
+ *
+ * Do this *after* defining the other printf-like functions, because otherwise the
+ * __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
+ * which confuses gcc.
+ */
+#define printf OutputDebugStringF
bool error(const char *format, ...);
void LogException(std::exception* pex, const char* pszThread);
@@ -237,9 +267,9 @@ inline int64 abs64(int64 n)
template<typename T>
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
{
- std::vector<char> rv;
- static char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ std::string rv;
+ static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
rv.reserve((itend-itbegin)*3);
for(T it = itbegin; it < itend; ++it)
{
@@ -250,7 +280,7 @@ std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
rv.push_back(hexmap[val&15]);
}
- return std::string(rv.begin(), rv.end());
+ return rv;
}
inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=false)
@@ -366,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++;