Skip to content

Commit

Permalink
Clarify the safety of NetClock::time_point arithmetic:
Browse files Browse the repository at this point in the history
* NetClock::rep is uint32_t and can be error-prone when
  used with subtraction.
* Fixes XRPLF#3656
  • Loading branch information
HowardHinnant committed Mar 9, 2021
1 parent c0a0b79 commit 5cb559e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/CreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ CreateOffer::takerCross(
Sandbox& sbCancel,
Amounts const& takerAmount)
{
NetClock::time_point const when{ctx_.view().parentCloseTime()};
NetClock::time_point const when = ctx_.view().parentCloseTime();

beast::WrappedSink takerSink(j_, "Taker ");

Expand Down
4 changes: 3 additions & 1 deletion src/ripple/consensus/Validations.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ isCurrent(
// Because this can be called on untrusted, possibly
// malicious validations, we do our math in a way
// that avoids any chance of overflowing or underflowing
// the signing time.
// the signing time. All of the expressions below are
// promoted from unsigned 32 bit to signed 64 bit prior
// to computation.

return (signTime > (now - p.validationCURRENT_EARLY)) &&
(signTime < (now + p.validationCURRENT_WALL)) &&
Expand Down

0 comments on commit 5cb559e

Please sign in to comment.