From 33208fb5575d76a19163e830617eaaf32dbacda8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 30 Jul 2011 23:01:45 +0200 Subject: [PATCH 01/14] Check for duplicate txins in CheckTransaction. --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index b57974f57..dccc1727f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -314,6 +314,15 @@ bool CTransaction::CheckTransaction() const return error("CTransaction::CheckTransaction() : txout total out of range"); } + // Check for duplicate inputs + set vInOutPoints; + BOOST_FOREACH(const CTxIn& txin, vin) + { + if (vInOutPoints.count(txin.prevout)) + return false; + vInOutPoints.insert(txin.prevout); + } + if (IsCoinBase()) { if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100) From fcedd45c3cd2085709155967545020e32e7de3c0 Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Sun, 26 Jun 2011 16:11:56 +0200 Subject: [PATCH 02/14] Add missing includes to key.h --- src/key.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/key.h b/src/key.h index 3c14cfedd..f880d1612 100644 --- a/src/key.h +++ b/src/key.h @@ -4,10 +4,17 @@ #ifndef BITCOIN_KEY_H #define BITCOIN_KEY_H +#include +#include + #include #include #include +#include "serialize.h" +#include "uint256.h" +#include "base58.h" + // secp160k1 // const unsigned int PRIVATE_KEY_SIZE = 192; // const unsigned int PUBLIC_KEY_SIZE = 41; From 437173f4300de9b1a5fa9d718857bb465c433e49 Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Wed, 29 Jun 2011 12:17:49 +0200 Subject: [PATCH 03/14] Add missing include to script.h --- src/script.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script.h b/src/script.h index 9d94e3f5c..b88083881 100644 --- a/src/script.h +++ b/src/script.h @@ -10,6 +10,8 @@ #include #include +#include + class CTransaction; enum From 8a62fec3ee03d3351acceb9d719157cfac2fb726 Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Wed, 29 Jun 2011 12:18:18 +0200 Subject: [PATCH 04/14] Add missing includes to net.h --- src/net.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.h b/src/net.h index 78055bfc6..d896defc8 100644 --- a/src/net.h +++ b/src/net.h @@ -6,6 +6,7 @@ #include #include +#include #include #ifndef __WXMSW__ From 02962ba848d1f7d58fe0f12a783400fc15e7260b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 31 Jul 2011 03:14:25 +0200 Subject: [PATCH 05/14] Add missing include to serialize.h --- src/serialize.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/serialize.h b/src/serialize.h index cb3a3ea03..c2bfa2780 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -34,6 +34,7 @@ typedef unsigned long long uint64; // Note that VirtualLock does not provide this as a guarantee on Windows, // but, in practice, memory that has been VirtualLock'd almost never gets written to // the pagefile except in rare circumstances where memory is extremely low. +#include #define mlock(p, n) VirtualLock((p), (n)); #define munlock(p, n) VirtualUnlock((p), (n)); #else From e707d29dd601bbe691175b72686caeaea29b1cbc Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Sun, 31 Jul 2011 20:00:38 +0200 Subject: [PATCH 06/14] Fix testing setup There were some problems with the existing testing setup: - Makefile rules for test-file compilation used CFLAGS instead of CXXFLAGS in makefile.unix --- src/makefile.linux-mingw | 2 +- src/makefile.mingw | 2 +- src/makefile.osx | 2 +- src/makefile.unix | 6 +++--- src/test/test_bitcoin.cpp | 10 ++++++++++ src/test/uint160_tests.cpp | 2 ++ src/test/uint256_tests.cpp | 2 ++ 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 59ff03c48..e2ef4213a 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -90,7 +90,7 @@ bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o obj/test/%.o: obj/test/%.cpp $(HEADERS) i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< -test_bitcoin.exe: obj/test/test_bitcoin.o +test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s diff --git a/src/makefile.mingw b/src/makefile.mingw index 16a054009..96f81b306 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -86,7 +86,7 @@ bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o obj/test/%.o: obj/test/%.cpp $(HEADERS) g++ -c $(CFLAGS) -o $@ $< -test_bitcoin: obj/test/test_bitcoin.o +test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) clean: diff --git a/src/makefile.osx b/src/makefile.osx index 89788562c..699911d4e 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -79,7 +79,7 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/test/%.o: test/%.cpp $(HEADERS) $(CXX) -c $(CFLAGS) -o $@ $< -test_bitcoin: obj/test/test_bitcoin.o +test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework clean: diff --git a/src/makefile.unix b/src/makefile.unix index 0567f8b75..ba9d0ca11 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -78,10 +78,10 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) obj/test/%.o: test/%.cpp $(HEADERS) - $(CXX) -c $(CFLAGS) -o $@ $< + $(CXX) -c $(CXXFLAGS) -o $@ $< -test_bitcoin: obj/test/test_bitcoin.o - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework +test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) + $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS) clean: -rm -f bitcoin bitcoind test_bitcoin diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 3b7d2d2f2..3d7ee9084 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -1,6 +1,16 @@ #define BOOST_TEST_MODULE uint160 #include +#include "../main.h" +#include "../wallet.h" + #include "uint160_tests.cpp" #include "uint256_tests.cpp" + +CWallet* pwalletMain; + +void Shutdown(void* parg) +{ + exit(0); +} diff --git a/src/test/uint160_tests.cpp b/src/test/uint160_tests.cpp index 66ffd285b..e85a9488e 100644 --- a/src/test/uint160_tests.cpp +++ b/src/test/uint160_tests.cpp @@ -1,3 +1,5 @@ +#include + #include "../uint256.h" BOOST_AUTO_TEST_SUITE(uint160_tests) diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index cbae9bf6d..f13b34944 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -1,3 +1,5 @@ +#include + #include "../uint256.h" BOOST_AUTO_TEST_SUITE(uint256_tests) From 5f6a654d3eb01cd1d324df4cbe2c7fe51dc3e752 Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Wed, 29 Jun 2011 12:33:21 +0200 Subject: [PATCH 07/14] Add prototype for EvalScript() to script.h This is needed for the script unit tests. --- src/script.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script.h b/src/script.h index b88083881..4b48bca7c 100644 --- a/src/script.h +++ b/src/script.h @@ -691,6 +691,7 @@ public: +bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType); bool IsStandard(const CScript& scriptPubKey); bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); From a8330e0049868eb3e2d1505719f3dba175711e74 Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Sun, 31 Jul 2011 20:01:31 +0200 Subject: [PATCH 08/14] Add a file for script tests --- src/test/script_tests.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/test/test_bitcoin.cpp | 1 + 2 files changed, 38 insertions(+) create mode 100644 src/test/script_tests.cpp diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp new file mode 100644 index 000000000..5e74648c4 --- /dev/null +++ b/src/test/script_tests.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + +#include "../main.h" +#include "../wallet.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(script_tests) + +BOOST_AUTO_TEST_CASE(script_PushData) +{ + // Check that PUSHDATA1, PUSHDATA2, and PUSHDATA4 create the same value on + // the stack as the 1-75 opcodes do. + static const unsigned char direct[] = { 1, 0x5a }; + static const unsigned char pushdata1[] = { OP_PUSHDATA1, 1, 0x5a }; + static const unsigned char pushdata2[] = { OP_PUSHDATA2, 1, 0, 0x5a }; + static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a }; + + vector > directStack; + BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, 0)); + + vector > pushdata1Stack; + BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata1Stack == directStack); + + vector > pushdata2Stack; + BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata2Stack == directStack); + + vector > pushdata4Stack; + BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata4Stack == directStack); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 3d7ee9084..6a9dac251 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -6,6 +6,7 @@ #include "uint160_tests.cpp" #include "uint256_tests.cpp" +#include "script_tests.cpp" CWallet* pwalletMain; From 3c8cecda1f26a10d22717dff7536b1c3fbc54358 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 31 Jul 2011 20:07:53 +0200 Subject: [PATCH 09/14] Add file for transaction tests. --- src/test/test_bitcoin.cpp | 1 + src/test/transaction_tests.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/transaction_tests.cpp diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 6a9dac251..a19d58bb6 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -7,6 +7,7 @@ #include "uint160_tests.cpp" #include "uint256_tests.cpp" #include "script_tests.cpp" +#include "transaction_tests.cpp" CWallet* pwalletMain; diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp new file mode 100644 index 000000000..e6eb0f054 --- /dev/null +++ b/src/test/transaction_tests.cpp @@ -0,0 +1,25 @@ +#include + +#include "../main.h" +#include "../wallet.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(transaction_tests) + +BOOST_AUTO_TEST_CASE(basic_transaction_tests) +{ + // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436) + unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; + vector vch(ch, ch + sizeof(ch) -1); + CDataStream stream(vch); + CTransaction tx; + stream >> tx; + BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "Simple deserialized transaction should be valid."); + + // Check that duplicate txins fail + tx.vin.push_back(tx.vin[0]); + BOOST_CHECK_MESSAGE(!tx.CheckTransaction(), "Transaction with duplicate txins should be invalid."); +} + +BOOST_AUTO_TEST_SUITE_END() From 2c3691d53d3f527638d4d9923c8a04488f459de0 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 2 Aug 2011 17:34:23 +0200 Subject: [PATCH 10/14] Cleanup test suite output to be more useful. --- src/test/test_bitcoin.cpp | 2 +- src/test/uint160_tests.cpp | 2 +- src/test/uint256_tests.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index a19d58bb6..0230bb6ec 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -1,4 +1,4 @@ -#define BOOST_TEST_MODULE uint160 +#define BOOST_TEST_MODULE Bitcoin Test Suite #include #include "../main.h" diff --git a/src/test/uint160_tests.cpp b/src/test/uint160_tests.cpp index e85a9488e..42c8275af 100644 --- a/src/test/uint160_tests.cpp +++ b/src/test/uint160_tests.cpp @@ -4,7 +4,7 @@ BOOST_AUTO_TEST_SUITE(uint160_tests) -BOOST_AUTO_TEST_CASE(equality) +BOOST_AUTO_TEST_CASE(uint160_equality) { uint160 num1 = 10; uint160 num2 = 11; diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index f13b34944..c5d45e215 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -4,7 +4,7 @@ BOOST_AUTO_TEST_SUITE(uint256_tests) -BOOST_AUTO_TEST_CASE(equality) +BOOST_AUTO_TEST_CASE(uint256_equality) { uint256 num1 = 10; uint256 num2 = 11; From 9f0ac16942d9f15ec57204448436cd429badf481 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 9 Aug 2011 12:38:17 -0400 Subject: [PATCH 11/14] Do-nothing MapPort() ifndef USE_UPNP. fixes #450 --- src/net.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/net.cpp b/src/net.cpp index d69778821..37adc13e1 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1143,6 +1143,11 @@ void MapPort(bool fMapPort) printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); } } +#else +void MapPort(bool /* unused fMapPort */) +{ + // Intentionally left blank. +} #endif From ec93a0e2197e8a84789c6c512cee90a66a11f82a Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Sun, 7 Aug 2011 12:18:05 -0400 Subject: [PATCH 12/14] Test for SO_NOSIGPIPE rather than assuming all BSDs support it. Signed-off-by: Jeff Garzik --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 37adc13e1..b52af24a5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -98,7 +98,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout SOCKET hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (hSocket == INVALID_SOCKET) return false; -#ifdef BSD +#ifdef SO_NOSIGPIPE int set = 1; setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif @@ -1584,7 +1584,7 @@ bool BindListenPort(string& strError) return false; } -#ifdef BSD +#ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif From 7c3002bf272c56dcc92b463db6d0b793221bfa8a Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Sun, 7 Aug 2011 12:20:00 -0400 Subject: [PATCH 13/14] Qualify make_tuple with boost:: namespace. db.cpp has a number of uses of make_tuple and has 'using namespace std' and 'using namespace boost'. Without qualifying make_tuple, std::make_tuple is preferred, which is incorrect. This patch qualifies make_tuple. Signed-off-by: Jeff Garzik --- src/db.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 9c8c9c4f7..b3fa3e173 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -610,7 +610,7 @@ bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account) bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) { - return Write(make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry); + return Write(boost::make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry); } int64 CWalletDB::GetAccountCreditDebit(const string& strAccount) @@ -638,7 +638,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list Date: Sun, 7 Aug 2011 12:19:14 -0400 Subject: [PATCH 14/14] Use 'unsigned char' rather than 'char' for pchMessageStart. Regarding https://bitcointalk.org/index.php?topic=28022.0 main.cpp has: "char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };" Per discussion on the thread linked, leaving the signedness of pchMessageStart is unsafe for values > 0x80. This patch specifies 'unsigned char' in main.cpp and net.h. Signed-off-by: Jeff Garzik --- src/main.cpp | 2 +- src/net.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b57974f57..4bcb87f61 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1766,7 +1766,7 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) // The message start string is designed to be unlikely to occur in normal data. // The characters are rarely used upper ascii, not valid as UTF-8, and produce // a large 4-byte int at any alignment. -char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; +unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) diff --git a/src/net.h b/src/net.h index 78055bfc6..6678e566a 100644 --- a/src/net.h +++ b/src/net.h @@ -66,7 +66,7 @@ bool StopNode(); // (4) size // (4) checksum -extern char pchMessageStart[4]; +extern unsigned char pchMessageStart[4]; class CMessageHeader {