Merge pull request #1 from MichelSantos/dapp-support
Merge with latest-fc
This commit is contained in:
commit
a17b231acf
9 changed files with 48 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
#include <assert.h>
|
||||
#include <utility>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
namespace fc {
|
||||
#ifdef _MSC_VER
|
||||
|
|
@ -22,12 +24,13 @@ namespace fc {
|
|||
public:
|
||||
typedef T value_type;
|
||||
|
||||
optional():_valid(false){}
|
||||
optional():_valid(false){ memset(_value, 0, sizeof(_value)); }
|
||||
~optional(){ reset(); }
|
||||
|
||||
optional( optional& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid ) new (ptr()) T( *o );
|
||||
_valid = o._valid;
|
||||
}
|
||||
|
|
@ -35,6 +38,7 @@ namespace fc {
|
|||
optional( const optional& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid ) new (ptr()) T( *o );
|
||||
_valid = o._valid;
|
||||
}
|
||||
|
|
@ -42,6 +46,7 @@ namespace fc {
|
|||
optional( optional&& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid ) new (ptr()) T( std::move(*o) );
|
||||
_valid = o._valid;
|
||||
o.reset();
|
||||
|
|
@ -51,6 +56,7 @@ namespace fc {
|
|||
optional( const optional<U>& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid ) new (ptr()) T( *o );
|
||||
_valid = o._valid;
|
||||
}
|
||||
|
|
@ -59,6 +65,7 @@ namespace fc {
|
|||
optional( optional<U>& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid )
|
||||
{
|
||||
new (ptr()) T( *o );
|
||||
|
|
@ -70,6 +77,7 @@ namespace fc {
|
|||
optional( optional<U>&& o )
|
||||
:_valid(false)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
if( o._valid ) new (ptr()) T( std::move(*o) );
|
||||
_valid = o._valid;
|
||||
o.reset();
|
||||
|
|
@ -79,6 +87,7 @@ namespace fc {
|
|||
optional( U&& u )
|
||||
:_valid(true)
|
||||
{
|
||||
memset(_value, 0, sizeof(_value));
|
||||
new ((char*)ptr()) T( std::forward<U>(u) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,10 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
|||
{
|
||||
mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
|
||||
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
|
||||
for (i = 0; i <= 143; ++i) {*p++ = 8;} for (; i <= 255; ++i) {*p++ = 9;} for (; i <= 279; ++i) {*p++ = 7;} for (; i <= 287; ++i) {*p++ = 8;}
|
||||
for ( i = 0; i <= 143; ++i) *p++ = 8;
|
||||
for ( ; i <= 255; ++i) *p++ = 9;
|
||||
for ( ; i <= 279; ++i) *p++ = 7;
|
||||
for ( ; i <= 287; ++i) *p++ = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2281,7 +2284,11 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
|
|||
if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
|
||||
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
|
||||
}
|
||||
if (!dist) {break;} q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) {continue;} p = s; probe_len = 32;
|
||||
if (!dist) break;
|
||||
q = (const mz_uint16*)(d->m_dict + probe_pos);
|
||||
if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue;
|
||||
p = s;
|
||||
probe_len = 32;
|
||||
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
|
||||
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
|
||||
if (!probe_len)
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ uint32_t aes_encoder::encode( const char* plaintxt, uint32_t plaintext_len, char
|
|||
FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc encryption update",
|
||||
("s", ERR_error_string( ERR_get_error(), nullptr) ) );
|
||||
}
|
||||
FC_ASSERT( (uint32_t) ciphertext_len == plaintext_len, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) );
|
||||
int64_t ciphertext_len_i64 = ciphertext_len;
|
||||
int64_t plaintext_len_i64 = plaintext_len;
|
||||
FC_ASSERT( ciphertext_len_i64 == plaintext_len_i64, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) );
|
||||
return ciphertext_len;
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -146,7 +148,9 @@ uint32_t aes_decoder::decode( const char* ciphertxt, uint32_t ciphertxt_len, cha
|
|||
FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc decryption update",
|
||||
("s", ERR_error_string( ERR_get_error(), nullptr) ) );
|
||||
}
|
||||
FC_ASSERT( ciphertxt_len == (uint32_t)plaintext_len, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) );
|
||||
int64_t ciphertxt_len_i64 = ciphertxt_len;
|
||||
int64_t plaintext_len_i64 = plaintext_len;
|
||||
FC_ASSERT( ciphertxt_len_i64 == plaintext_len_i64, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) );
|
||||
return plaintext_len;
|
||||
}
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -83,8 +83,10 @@ namespace fc { namespace ecc {
|
|||
ssl_bignum order;
|
||||
FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) );
|
||||
private_key_secret bin;
|
||||
FC_ASSERT( (size_t) BN_num_bytes( order ) == bin.data_size() );
|
||||
FC_ASSERT( (size_t) BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() );
|
||||
size_t order_BN_num_bytes = BN_num_bytes( order );
|
||||
FC_ASSERT( order_BN_num_bytes == bin.data_size() );
|
||||
size_t order_BN_bn2bin = BN_bn2bin( order, (unsigned char*) bin.data() );
|
||||
FC_ASSERT( order_BN_bn2bin == bin.data_size() );
|
||||
return bin;
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +104,10 @@ namespace fc { namespace ecc {
|
|||
FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) );
|
||||
BN_rshift1( order, order );
|
||||
private_key_secret bin;
|
||||
FC_ASSERT( (size_t) BN_num_bytes( order ) == bin.data_size() );
|
||||
FC_ASSERT( (size_t) BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() );
|
||||
size_t order_BN_num_bytes = BN_num_bytes( order );
|
||||
FC_ASSERT( order_BN_num_bytes == bin.data_size() );
|
||||
size_t order_BN_bn2bin = BN_bn2bin( order, (unsigned char*) bin.data() );
|
||||
FC_ASSERT( order_BN_bn2bin == bin.data_size() );
|
||||
return bin;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ bool operator == ( const ripemd160& h1, const ripemd160& h2 ) {
|
|||
void from_variant( const variant& v, ripemd160& bi, uint32_t max_depth )
|
||||
{
|
||||
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
|
||||
memset( &bi, char(0), sizeof(bi) );
|
||||
for (size_t i = 0; i < bi.data_size(); i++) {
|
||||
bi.data()[i] = 0;
|
||||
}
|
||||
if( ve.size() )
|
||||
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,9 @@ bool operator == ( const sha1& h1, const sha1& h2 ) {
|
|||
void from_variant( const variant& v, sha1& bi, uint32_t max_depth )
|
||||
{
|
||||
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
|
||||
memset( &bi, char(0), sizeof(bi) );
|
||||
for (size_t i = 0; i < bi.data_size(); i++) {
|
||||
bi.data()[i] = 0;
|
||||
}
|
||||
if( ve.size() )
|
||||
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,9 @@ namespace fc {
|
|||
void from_variant( const variant& v, sha224& bi, uint32_t max_depth )
|
||||
{
|
||||
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
|
||||
memset( &bi, char(0), sizeof(bi) );
|
||||
for (size_t i = 0; i < bi.data_size(); i++) {
|
||||
bi.data()[i] = 0;
|
||||
}
|
||||
if( ve.size() )
|
||||
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ namespace fc {
|
|||
void from_variant( const variant& v, sha256& bi, uint32_t max_depth )
|
||||
{
|
||||
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
|
||||
memset( &bi, char(0), sizeof(bi) );
|
||||
for (size_t i = 0; i < bi.data_size(); i++) {
|
||||
bi.data()[i] = 0;
|
||||
}
|
||||
if( ve.size() )
|
||||
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,9 @@ namespace fc {
|
|||
void from_variant( const variant& v, sha512& bi, uint32_t max_depth )
|
||||
{
|
||||
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
|
||||
memset( &bi, char(0), sizeof(bi) );
|
||||
for (size_t i = 0; i < bi.data_size(); i++) {
|
||||
bi.data()[i] = 0;
|
||||
}
|
||||
if( ve.size() )
|
||||
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue