Merge branch 'release' into develop

Conflicts:
	Builds/VisualStudio2013/RippleD.vcxproj
	Builds/VisualStudio2013/RippleD.vcxproj.filters
	Builds/rpm/rippled.spec
	src/ripple/app/misc/NetworkOPs.cpp
	src/ripple/app/tx/impl/TransactionEngine.cpp
	src/ripple/protocol/impl/BuildInfo.cpp
	src/ripple/unity/app_tx.cpp
This commit is contained in:
Vinnie Falco
2015-07-07 09:35:41 -07:00
14 changed files with 113 additions and 58 deletions

View File

@@ -1839,6 +1839,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\impl\TransactionEngine.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\impl\TransactionMaster.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
@@ -1877,6 +1881,10 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\tests\PathSet.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\tests\Regression_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\tests\Taker.test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>

View File

@@ -2571,6 +2571,9 @@
<ClCompile Include="..\..\src\ripple\app\tx\impl\TransactionAcquire.cpp">
<Filter>ripple\app\tx\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\impl\TransactionEngine.cpp">
<Filter>ripple\app\tx\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\impl\TransactionMaster.cpp">
<Filter>ripple\app\tx\impl</Filter>
</ClCompile>
@@ -2607,6 +2610,9 @@
<ClInclude Include="..\..\src\ripple\app\tx\tests\PathSet.h">
<Filter>ripple\app\tx\tests</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\tests\Regression_test.cpp">
<Filter>ripple\app\tx\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\tx\tests\Taker.test.cpp">
<Filter>ripple\app\tx\tests</Filter>
</ClCompile>

View File

@@ -245,6 +245,9 @@ public:
Blob (node.nodedata().begin(), node.nodedata().end()),
0, snfWIRE, uZero, false);
if (!newNode)
return;
s.erase();
newNode->addRaw(s, snfPREFIX);

View File

@@ -152,7 +152,7 @@ public:
private:
std::uint32_t getCloseTimeNC (int& offset) const;
bool isValidated (std::uint32_t seq, uint256 const& hash) /*override*/;
bool isValidated (std::uint32_t seq, uint256 const& hash);
public:
void closeTimeOffset (int) override;

View File

@@ -0,0 +1,47 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <BeastConfig.h>
#include <ripple/test/jtx.h>
namespace ripple {
namespace test {
struct Regression_test : public beast::unit_test::suite
{
// SigningPubKey: 0000000000000000000000000000000000 (34 zeroes)
void testBadSigningPubKey()
{
using namespace jtx;
Env env(*this);
env.fund(XRP(10000), "alice");
env(noop("alice"), sig(none), json( R"raw( {
"SigningPubKey" : "0000000000000000000000000000000000",
"TxnSignature" : "3044022042D144D130A1651CBE5632196FE4E745A75445AA8DB95AC9905701DC891F9A30022012DF180ED1545B560681D475F570D9603BF663BD4C91F591DBA0A8C43876C563"
} )raw"), ter(temINVALID));
}
void run() override
{
testBadSigningPubKey();
}
};
BEAST_DEFINE_TESTSUITE(Regression,app,ripple);
} // test
} // ripple

View File

@@ -71,7 +71,7 @@ static bool ECDSAVerify (uint256 const& hash, std::uint8_t const* sig, size_t si
static bool ECDSAVerify (uint256 const& hash, Blob const& sig, const openssl::ec_key& key)
{
return ECDSAVerify (hash, sig.data(), sig.size(), (EC_KEY*) key.get());
return key.valid() && ECDSAVerify (hash, sig.data(), sig.size(), (EC_KEY*) key.get());
}
bool ECDSAVerify (uint256 const& hash,

View File

@@ -55,33 +55,34 @@ ec_key ECDSAPrivateKey (uint256 const& serialized)
}
EC_KEY* key = new_initialized_EC_KEY();
ec_key::pointer_t ptr = nullptr;
const bool ok = EC_KEY_set_private_key (key, bn);
BN_clear_free (bn);
if (! ok)
{
if (ok)
ptr = (ec_key::pointer_t) key;
else
EC_KEY_free (key);
}
return ec_key::acquire ((ec_key::pointer_t) key);
return ec_key(ptr);
}
ec_key ECDSAPublicKey (std::uint8_t const* data, std::size_t size)
{
EC_KEY* key = new_initialized_EC_KEY();
ec_key::pointer_t ptr = nullptr;
if (o2i_ECPublicKey (&key, &data, size) != nullptr)
{
EC_KEY_set_conv_form (key, POINT_CONVERSION_COMPRESSED);
ptr = (ec_key::pointer_t) key;
}
else
{
EC_KEY_free (key);
}
return ec_key::acquire ((ec_key::pointer_t) key);
return ec_key(ptr);
}
ec_key ECDSAPublicKey (Blob const& serialized)

View File

@@ -34,8 +34,6 @@ static inline EC_KEY* get_EC_KEY (const ec_key& that)
return (EC_KEY*) that.get();
}
const ec_key ec_key::invalid = ec_key::acquire (nullptr);
ec_key::ec_key (const ec_key& that)
{
if (that.ptr == nullptr)

View File

@@ -31,32 +31,28 @@ class ec_key
public:
using pointer_t = struct opaque_EC_KEY*;
private:
pointer_t ptr;
void destroy();
ec_key () : ptr(nullptr)
{
}
ec_key (pointer_t raw) : ptr(raw)
{
}
public:
static const ec_key invalid;
static ec_key acquire (pointer_t raw) { return ec_key (raw); }
//ec_key() : ptr() {}
ec_key (const ec_key&);
ec_key& operator= (const ec_key&) = delete;
~ec_key()
{
destroy();
}
bool valid() const
{
return ptr != nullptr;
}
pointer_t get() const { return ptr; }
ec_key (const ec_key&);
pointer_t release()
{
pointer_t released = ptr;
@@ -66,7 +62,12 @@ public:
return released;
}
bool valid() const { return ptr != nullptr; }
private:
pointer_t ptr;
void destroy();
ec_key& operator= (const ec_key&) = delete;
};
} // openssl

View File

@@ -133,7 +133,7 @@ static ec_key ec_key_new_secp256k1_compressed()
EC_KEY_set_conv_form (key, POINT_CONVERSION_COMPRESSED);
return ec_key::acquire ((ec_key::pointer_t) key);
return ec_key((ec_key::pointer_t) key);
}
void serialize_ec_point (ec_point const& point, std::uint8_t* ptr)

View File

@@ -180,7 +180,8 @@ SHAMap::fetchNodeFromDB (uint256 const& hash) const
{
node = SHAMapAbstractNode::make(obj->getData(),
0, snfPREFIX, hash, true);
canonicalize (hash, node);
if (node)
canonicalize (hash, node);
}
catch (...)
{
@@ -209,9 +210,12 @@ SHAMap::checkFilter(uint256 const& hash, SHAMapNodeID const& id,
if (filter->haveNode (id, hash, nodeData))
{
node = SHAMapAbstractNode::make(nodeData, 0, snfPREFIX, hash, true);
filter->gotNode (true, id, hash, nodeData, node->getType ());
if (backed_)
canonicalize (hash, node);
if (node)
{
filter->gotNode (true, id, hash, nodeData, node->getType ());
if (backed_)
canonicalize (hash, node);
}
}
return node;
}
@@ -382,7 +386,7 @@ SHAMap::descendAsync (SHAMapInnerNode* parent, int branch,
ptr = SHAMapAbstractNode::make(obj->getData(), 0, snfPREFIX, hash, true);
if (backed_)
if (ptr && backed_)
canonicalize (hash, ptr);
}
}

View File

@@ -419,7 +419,7 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode,
assert (seq_ >= 1);
auto node = SHAMapAbstractNode::make(rootNode, 0, format, uZero, false);
if (!node)
if (!node || !node->isValid ())
return SHAMapAddNode::invalid ();
#ifdef BEAST_DEBUG
@@ -459,7 +459,7 @@ SHAMapAddNode SHAMap::addRootNode (uint256 const& hash, Blob const& rootNode, SH
assert (seq_ >= 1);
auto node = SHAMapAbstractNode::make(rootNode, 0, format, uZero, false);
if (!node || node->getNodeHash () != hash)
if (!node || !node->isValid() || node->getNodeHash () != hash)
return SHAMapAddNode::invalid ();
if (backed_)
@@ -537,6 +537,13 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode,
auto newNode = SHAMapAbstractNode::make(rawNode, 0, snfWIRE, uZero, false);
if (!newNode || !newNode->isValid() || childHash != newNode->getNodeHash ())
{
if (journal_.warning) journal_.warning <<
"Corrupt node received";
return SHAMapAddNode::invalid ();
}
if (!newNode->isInBounds (iNodeID))
{
// Map is provably invalid
@@ -544,13 +551,6 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode,
return SHAMapAddNode::useful ();
}
if (childHash != newNode->getNodeHash ())
{
if (journal_.warning) journal_.warning <<
"Corrupt node received";
return SHAMapAddNode::invalid ();
}
if (backed_)
canonicalize (childHash, newNode);

View File

@@ -79,28 +79,14 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f
if (format == snfWIRE)
{
if (rawNode.empty ())
{
#ifdef BEAST_DEBUG
deprecatedLogs().journal("SHAMapTreeNode").fatal <<
"Wire format node is empty";
assert (false);
#endif
throw std::runtime_error ("invalid node AW type");
}
return {};
Serializer s (rawNode.data(), rawNode.size() - 1);
int type = rawNode.back ();
int len = s.getLength ();
if ((type < 0) || (type > 4))
{
#ifdef BEAST_DEBUG
deprecatedLogs().journal("SHAMapTreeNode").fatal <<
"Invalid wire format node" << strHex (rawNode);
assert (false);
#endif
throw std::runtime_error ("invalid node AW type");
}
return {};
if (type == 0)
{

View File

@@ -43,8 +43,9 @@
#include <ripple/app/tx/impl/Transactor.cpp>
#include <ripple/app/tx/tests/common_transactor.cpp>
#include <ripple/app/tx/tests/DeliverMin.test.cpp>
#include <ripple/app/tx/tests/MultiSign.test.cpp>
#include <ripple/app/tx/tests/OfferStream.test.cpp>
#include <ripple/app/tx/tests/Offer.test.cpp>
#include <ripple/app/tx/tests/Regression_test.cpp>
#include <ripple/app/tx/tests/Taker.test.cpp>
#include <ripple/app/tx/tests/DeliverMin.test.cpp>