Merge pull request #111 from peerplays-network/feature/GRPH-88

GRPH-88 - Fixed integer overflow issue
This commit is contained in:
Alfredo Garcia 2019-09-17 15:48:33 -03:00 committed by GitHub
commit 44137a30a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -230,8 +230,16 @@ namespace graphene { namespace chain {
share_type settlement_fund;
///@}
/// The time when @ref current_feed would expire
time_point_sec feed_expiration_time()const
{ return current_feed_publication_time + options.feed_lifetime_sec; }
{
uint32_t current_feed_seconds = current_feed_publication_time.sec_since_epoch();
if( std::numeric_limits<uint32_t>::max() - current_feed_seconds <= options.feed_lifetime_sec )
return time_point_sec::maximum();
else
return current_feed_publication_time + options.feed_lifetime_sec;
}
bool feed_is_expired_before_hardfork_615(time_point_sec current_time)const
{ return feed_expiration_time() >= current_time; }
bool feed_is_expired(time_point_sec current_time)const

View file

@ -540,4 +540,19 @@ BOOST_AUTO_TEST_CASE( merkle_root )
BOOST_CHECK( block.calculate_merkle_root() == c(dO) );
}
/**
* Reproduces https://github.com/bitshares/bitshares-core/issues/888 and tests fix for it.
*/
BOOST_AUTO_TEST_CASE( bitasset_feed_expiration_test )
{
time_point_sec now = fc::time_point::now();
asset_bitasset_data_object o;
o.current_feed_publication_time = now - fc::hours(1);
o.options.feed_lifetime_sec = std::numeric_limits<uint32_t>::max() - 1;
BOOST_CHECK( !o.feed_is_expired( now ) );
}
BOOST_AUTO_TEST_SUITE_END()