Skip to content

Commit

Permalink
Prevent datatimes from overflowing or underflowing 32-bit signed inte…
Browse files Browse the repository at this point in the history
…gers
  • Loading branch information
sgerbino committed Jul 15, 2019
1 parent 65a92d0 commit a8b3ddb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libraries/fc/src/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace fc {
pt = boost::date_time::parse_delimited_time<boost::posix_time::ptime>( s, 'T' );
else
pt = boost::posix_time::from_iso_string( s );

FC_ASSERT( (pt - epoch).total_seconds() <= INT32_MAX, "Datetime overflow" );
FC_ASSERT( (pt - epoch).total_seconds() >= INT32_MIN, "Datetime underflow" );
return fc::time_point_sec( (pt - epoch).total_seconds() );
} FC_RETHROW_EXCEPTIONS( warn, "unable to convert ISO-formatted string to fc::time_point_sec" ) }

Expand Down

0 comments on commit a8b3ddb

Please sign in to comment.