Commit Graph

20 Commits

Author SHA1 Message Date
Homu 2d1a3cf8f5 Auto merge of #3183 - bitcartel:least_authority_issue_d, r=str4d
Closes #3182 - Least Authority Issue D

Prevent undefined behaviour when null pointer is passed in as parameter to function

Includes a backport of bitcoin/bitcoin#10250.
2018-05-03 16:39:10 -07:00
Simon 54a872f0fa Fix undefined behaviour, calling memcpy with NULL pointer.
Identified as part of audit: Least Authority, Issue D.
2018-04-30 16:41:02 -07:00
Pieter Wuille 1878f3a759 Fix some empty vector references
streams.h has some methods that can be tricked into dereferencing
null pointers or end() iterators. Fix this.
2018-04-18 21:31:14 -07:00
Jack Grigg b7e75b17af
Implement basic Sapling v4 transaction parser
Details of Sapling datatypes will be filled in later; for now, they are treated
as binary blobs.

Includes code cherry-picked from upstream commit:
    7030d9eb47254499bba14f1c00abc6bf493efd91
    BIP144: Serialization, hashes, relay (sender side)
2018-04-19 05:01:47 +01:00
Pieter Wuille 242f1421db
Get rid of nType and nVersion
Remove the nType and nVersion as parameters to all serialization methods
and functions. There is only one place where it's read and has an impact
(in CAddress), and even there it does not impact any of the recursively
invoked serializers.

Instead, the few places that need nType or nVersion are changed to read
it directly from the stream object, through GetType() and GetVersion()
methods which are added to all stream classes.
2018-04-17 13:09:28 +01:00
Pieter Wuille b8a6579366
Make GetSerializeSize a wrapper on top of CSizeComputer
Given that in default GetSerializeSize implementations created by
ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
of the specialized GetSerializeSize methods everywhere, and just use
CSizeComputer. This removes a lot of code which isn't actually used
anywhere.

For CCompactSize and CVarInt this actually removes a more efficient
size computing algorithm, which is brought back in a later commit.
2018-04-16 07:38:38 -06:00
Pieter Wuille 7f4acac433
Make nType and nVersion private and sometimes const
Make the various stream implementations' nType and nVersion private
and const (except in CDataStream where we really need a setter).
2018-04-16 07:38:37 -06:00
Pieter Wuille 1315591c85
Make streams' read and write return void
The stream implementations had two cascading layers (the upper one
with operator<< and operator>>, and a lower one with read and write).
The lower layer's functions are never cascaded (nor should they, as
they should only be used from the higher layer), so make them return
void instead.
2018-04-16 07:38:37 -06:00
Pieter Wuille 670a7686a6
Remove unused ReadVersion and WriteVersion
CDataStream and CAutoFile had a ReadVersion and WriteVersion method
that was never used. Remove them.
2018-04-16 07:38:37 -06:00
Cory Fields d1c9ef8606
serialization: teach serializers variadics
Also add a variadic CDataStream ctor for ease-of-use.
2018-04-16 07:38:37 -06:00
Pavel Janík f0e9019223
Prevent -Wshadow warnings with gcc versions 4.8.5, 5.3.1 and 6.2.1.
Zcash: partial (ignoring src/test/script_tests.cpp due to merge conflicts)
2017-03-25 20:25:56 +13:00
Patrick Strateman e9d221e764 CDataStream::ignore Throw exception instead of assert on negative nSize.
Previously disk corruption would cause an assert instead of an exception.
2016-10-20 22:59:50 -07:00
Pieter Wuille f588c5edd6 Fix OOM bug: UTXO entries with invalid script length 2016-10-20 22:59:50 -07:00
Jack Grigg 6bffc46a87 Implement CSecureDataStream for streaming CKeyingMaterial 2016-09-28 13:44:53 +13:00
Cory Fields d7d187e8a4 allocators: split allocators and pagelocker
Pagelocker is only needed for secure (usually wallet) operations, so don't make
the zero-after-free allocator depend on it.
2015-03-20 12:23:44 +01:00
Cory Fields 1630219d90 openssl: abstract out OPENSSL_cleanse
This makes it easier for us to replace it if desired, since it's now only in
one spot. Also, it avoids the openssl include from allocators.h, which
essentially forced openssl to be included from every compilation unit.
2015-02-15 11:34:02 -05:00
Pavel Janík 5262fde0ec Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Cory Fields fa7361907a boost: split stream classes out of serialize.h
serialization now has no dependencies.
2014-10-22 15:21:06 -04:00