Skip to content

Commit

Permalink
Auto merge of zcash#1571 - daira:1459.avoid-boost-posix-time, r=daira
Browse files Browse the repository at this point in the history
Avoid boost::posix_time functions that have potential out-of-bounds read bugs

ref zcash#1459

Signed-off-by: Daira Hopwood <[email protected]>
  • Loading branch information
zkbot committed Oct 20, 2016
2 parents b492ef3 + a652e41 commit bb891cb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utiltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "utiltime.h"

#include <chrono>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>

Expand All @@ -30,14 +31,14 @@ void SetMockTime(int64_t nMockTimeIn)

int64_t GetTimeMillis()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}

int64_t GetTimeMicros()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
return std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
}

void MilliSleep(int64_t n)
Expand Down

0 comments on commit bb891cb

Please sign in to comment.