bitcoin/src
Gavin Andresen 8dc206a1e2 Reject non-canonically-encoded sizes
The length of vectors, maps, sets, etc are serialized using
Write/ReadCompactSize -- which, unfortunately, do not use a
unique encoding.

So deserializing and then re-serializing a transaction (for example)
can give you different bits than you started with. That doesn't
cause any problems that we are aware of, but it is exactly the type
of subtle mismatch that can lead to exploits.

With this pull, reading a non-canonical CompactSize throws an
exception, which means nodes will ignore 'tx' or 'block' or
other messages that are not properly encoded.

Please check my logic... but this change is safe with respect to
causing a network split. Old clients that receive
non-canonically-encoded transactions or blocks deserialize
them into CTransaction/CBlock structures in memory, and then
re-serialize them before relaying them to peers.

And please check my logic with respect to causing a blockchain
split: there are no CompactSize fields in the block header, so
the block hash is always canonical. The merkle root in the block
header is computed on a vector<CTransaction>, so
any non-canonical encoding of the transactions in 'tx' or 'block'
messages is erased as they are read into memory by old clients,
and does not affect the block hash. And, as noted above, old
clients re-serialize (with canonical encoding) 'tx' and 'block'
messages before relaying to peers.
2013-08-09 10:01:35 +10:00
..
json Back out spacing changes to json spirit code 2012-01-19 14:32:45 -05:00
leveldb Merge commit 'adae78ea9940f4d44382967d1296e7db0b54a4de' into leveldb-squashed 2013-07-01 08:36:32 -07:00
obj Bump version numbers for 0.6.1rc1 2012-04-27 10:14:33 -04:00
obj-test Rename src/obj/test to src/obj-test to workaround bug in older GNU Make 2012-01-23 14:27:08 -05:00
qt remove a newline from a string in init.cpp 2013-08-06 10:28:52 +02:00
test Reject non-canonically-encoded sizes 2013-08-09 10:01:35 +10:00
addrman.cpp Split off hash.h from util.h 2012-12-18 21:39:29 +01:00
addrman.h Trim trailing whitespace for src/*.{h,cpp} 2012-09-18 15:07:58 -04:00
alert.cpp Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
alert.h -alertnotify=<cmd> 2013-03-19 15:16:30 -04:00
allocators.h Make signature cache store CPubKeys 2013-05-30 05:20:23 +02:00
base58.h Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
bignum.h Use a uint256 for bnChainWork 2013-04-12 12:17:28 +02:00
bitcoind.cpp exclude CreatePidFile() function on WIN32 as it is unused 2013-07-24 09:30:09 +02:00
bitcoinrpc.cpp Remove #define loop from util.h 2013-07-31 14:06:44 +10:00
bitcoinrpc.h RPC: add getbestblockhash, to return tip of best chain 2013-07-03 11:02:29 -04:00
bloom.cpp main.h->core.h include dependency improvements. 2013-06-24 10:41:16 -04:00
bloom.h Add nFlags to CBloomFilter to make filter updating optional. 2013-01-16 14:34:06 -05:00
chainparams.cpp main.h->core.h include dependency improvements. 2013-06-24 10:41:16 -04:00
chainparams.h Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
checkpoints.cpp Don't use checkpoints and accept nonstd txn on -regtest 2013-07-23 18:02:26 +02:00
checkpoints.h Replace repeated GetBoolArg() calls with Checkpoint::fEnabled variable 2013-05-24 11:10:53 -04:00
checkqueue.h Port Thread* methods to boost::thread_group 2013-04-03 19:57:13 -04:00
clientversion.h Prepare for 0.9 merge window 2013-05-30 04:43:51 +02:00
compat.h cleanup compat.h Windows stuff 2013-07-24 16:24:38 +02:00
core.cpp Move core implementations to core.cpp 2013-06-25 10:33:29 +02:00
core.h Move core implementations to core.cpp 2013-06-25 10:33:29 +02:00
crypter.cpp CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
crypter.h CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
db.cpp Bugfix: Move boost/version include from db.cpp to walletdb.cpp where BOOST_VERSION is used 2013-07-15 22:16:42 +00:00
db.h Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
hash.cpp Add MurmurHash3 implementation to hash.h/add hash.cpp. 2013-01-16 12:48:01 -05:00
hash.h Make CPubKey statically allocated 2013-05-30 05:18:42 +02:00
init.cpp remove a newline from a string in init.cpp 2013-08-06 10:28:52 +02:00
init.h let user select wallet file with -wallet=foo.dat 2013-07-04 17:19:36 +02:00
key.cpp Fix minor backward incompatibility 2013-07-13 12:57:19 +02:00
key.h Make signature cache store CPubKeys 2013-05-30 05:20:23 +02:00
keystore.cpp CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
keystore.h CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
leveldb.cpp Reduce number of open LevelDB files to 64 2013-04-24 00:10:23 +02:00
leveldb.h Deal with LevelDB errors 2013-01-30 04:30:02 +01:00
limitedmap.h Add a limitedmap class similar to mruset 2013-04-01 11:56:22 -04:00
main.cpp Reject non-canonically-encoded sizes 2013-08-09 10:01:35 +10:00
main.h Simplify storage of orphan transactions 2013-08-02 16:10:25 +10:00
makefile.linux-mingw Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
makefile.mingw Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
makefile.osx Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
makefile.unix Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
miner.cpp Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
miner.h Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
mruset.h If (for example) the new max_size must be 5 then at the end the queue.size() must be <= 5, so the exit condition must be <=, so the continuing condition must be > (and not >= as it was). 2012-06-19 09:48:00 +03:00
net.cpp Remove #define loop from util.h 2013-07-31 14:06:44 +10:00
net.h Removed the main.h include from net.cpp. 2013-06-06 00:04:33 -07:00
netbase.cpp fix !O_NONBLOCK where ~O_NONBLOCK was meant 2013-04-27 15:37:26 +02:00
netbase.h Merge pull request #1913 from sipa/noi2p 2012-10-11 00:41:33 -07:00
noui.cpp Improve block database load error reporting 2013-02-17 23:25:42 +01:00
protocol.cpp Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
protocol.h Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
rpcblockchain.cpp RPC: add getbestblockhash, to return tip of best chain 2013-07-03 11:02:29 -04:00
rpcdump.cpp Add dumpwallet and importwallet RPCs 2013-06-22 17:30:56 +02:00
rpcmining.cpp Move internal miner/block creation to separate miner.cpp module. 2013-07-31 09:43:35 -04:00
rpcnet.cpp Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
rpcrawtransaction.cpp main.h->core.h include dependency improvements. 2013-06-24 10:41:16 -04:00
rpcwallet.cpp Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
script.cpp Remove #define loop from util.h 2013-07-31 14:06:44 +10:00
script.h Add ExtractAffectedKeys to script 2013-06-22 16:49:30 +02:00
serialize.h Reject non-canonically-encoded sizes 2013-08-09 10:01:35 +10:00
sync.cpp Trim trailing whitespace for src/*.{h,cpp} 2012-09-18 15:07:58 -04:00
sync.h Added comments to sync.h to make it easier to understand the macros 2013-06-25 16:54:58 -07:00
threadsafety.h o Added threadsafety.h - a set of macros using the -Wthread-safety 2012-11-11 00:53:00 -03:00
txdb.cpp Introduce a CChainParameters singleton class and regtest mode. 2013-06-19 16:28:52 +02:00
txdb.h Merge pull request #2221 from sipa/perfo 2013-02-22 09:01:30 -08:00
ui_interface.h Have Qt poll for shutdown requested, the QT way. 2013-04-03 19:58:47 -04:00
uint256.h Specified base_uint component size 2013-05-07 20:03:17 -05:00
util.cpp Merge pull request #2855 from Diapolo/guard_CreatePidFile 2013-08-05 01:05:59 -07:00
util.h Merge pull request #2855 from Diapolo/guard_CreatePidFile 2013-08-05 01:05:59 -07:00
version.cpp Fix build date for from-tarball builds 2013-06-29 14:16:50 +02:00
version.h Bump PROTOCOL_VERSION for filter messages. 2013-01-16 12:48:02 -05:00
wallet.cpp Remove #define loop from util.h 2013-07-31 14:06:44 +10:00
wallet.h Make sure new wallet variables are initialized 2013-07-29 02:34:01 +02:00
walletdb.cpp Remove #define loop from util.h 2013-07-31 14:06:44 +10:00
walletdb.h Refactor keytime/metadata and wallet encryption bugfix 2013-06-20 01:31:18 +02:00