Browse Source

gossipd: ensure incoming timestamps are reasonable.

This is kind of orthogonal to the other changes, but makes sense: if we
would instantly or never prune the message, don't accept it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
97bb6c5a28
  1. 22
      gossipd/routing.c

22
gossipd/routing.c

@ -1071,6 +1071,28 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update,
}
}
/* BOLT #7:
*
* - if the `timestamp` is unreasonably far in the future:
* - MAY discard the `channel_announcement`.
*/
if (timestamp > time_now().ts.tv_sec + rstate->prune_timeout) {
status_debug("Received channel_update for %s with far time %u",
type_to_string(tmpctx, struct short_channel_id,
&short_channel_id),
timestamp);
return NULL;
}
/* Note: we can consider old timestamps a case of "instant prune" too */
if (timestamp < time_now().ts.tv_sec - rstate->prune_timeout) {
status_debug("Received channel_update for %s with old time %u",
type_to_string(tmpctx, struct short_channel_id,
&short_channel_id),
timestamp);
return NULL;
}
c = &chan->half[direction];
if (is_halfchan_defined(c) && timestamp <= c->last_timestamp) {

Loading…
Cancel
Save