Fixed integer overflow issue
This commit is contained in:
parent
6943a0bfbd
commit
99699d8a4d
2 changed files with 24 additions and 1 deletions
|
|
@ -230,8 +230,16 @@ namespace graphene { namespace chain {
|
||||||
share_type settlement_fund;
|
share_type settlement_fund;
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
|
/// The time when @ref current_feed would expire
|
||||||
time_point_sec feed_expiration_time()const
|
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
|
bool feed_is_expired_before_hardfork_615(time_point_sec current_time)const
|
||||||
{ return feed_expiration_time() >= current_time; }
|
{ return feed_expiration_time() >= current_time; }
|
||||||
bool feed_is_expired(time_point_sec current_time)const
|
bool feed_is_expired(time_point_sec current_time)const
|
||||||
|
|
|
||||||
|
|
@ -540,4 +540,19 @@ BOOST_AUTO_TEST_CASE( merkle_root )
|
||||||
BOOST_CHECK( block.calculate_merkle_root() == c(dO) );
|
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()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue