mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 14:51:11 +01:00
Merge branch 'ticket31343_029' into ticket31343_035
This commit is contained in:
commit
bc9492a938
2 changed files with 29 additions and 4 deletions
9
changes/bug31343
Normal file
9
changes/bug31343
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
o Minor bugfixes (compilation):
|
||||||
|
- Avoid using labs() on time_t, which can cause compilation warnings
|
||||||
|
on 64-bit Windows builds. Fixes bug 31343; bugfix on 0.2.4.4-alpha.
|
||||||
|
|
||||||
|
o Minor bugfixes (clock skew detection):
|
||||||
|
- Don't believe clock skew results from NETINFO cells that appear to
|
||||||
|
arrive before the VERSIONS cells they are responding to were sent.
|
||||||
|
Previously, we would accept them up to 3 minutes "in the past".
|
||||||
|
Fixes bug 31343; bugfix on 0.2.4.4-alpha.
|
|
@ -1637,7 +1637,19 @@ channel_tls_process_padding_negotiate_cell(cell_t *cell, channel_tls_t *chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a 'netinfo' cell.
|
* Helper: compute the absolute value of a time_t.
|
||||||
|
*
|
||||||
|
* (we need this because labs() doesn't always work for time_t, since
|
||||||
|
* long can be shorter than time_t.)
|
||||||
|
*/
|
||||||
|
static inline time_t
|
||||||
|
time_abs(time_t val)
|
||||||
|
{
|
||||||
|
return (val < 0) ? -val : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a 'netinfo' cell
|
||||||
*
|
*
|
||||||
* This function is called to handle an incoming NETINFO cell; read and act
|
* This function is called to handle an incoming NETINFO cell; read and act
|
||||||
* on its contents, and set the connection state to "open".
|
* on its contents, and set the connection state to "open".
|
||||||
|
@ -1654,7 +1666,7 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
const routerinfo_t *me = router_get_my_routerinfo();
|
const routerinfo_t *me = router_get_my_routerinfo();
|
||||||
|
|
||||||
long apparent_skew = 0;
|
time_t apparent_skew = 0;
|
||||||
tor_addr_t my_apparent_addr = TOR_ADDR_NULL;
|
tor_addr_t my_apparent_addr = TOR_ADDR_NULL;
|
||||||
int started_here = 0;
|
int started_here = 0;
|
||||||
const char *identity_digest = NULL;
|
const char *identity_digest = NULL;
|
||||||
|
@ -1721,7 +1733,11 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
|
||||||
|
|
||||||
/* Decode the cell. */
|
/* Decode the cell. */
|
||||||
timestamp = ntohl(get_uint32(cell->payload));
|
timestamp = ntohl(get_uint32(cell->payload));
|
||||||
if (labs(now - chan->conn->handshake_state->sent_versions_at) < 180) {
|
const time_t sent_versions_at =
|
||||||
|
chan->conn->handshake_state->sent_versions_at;
|
||||||
|
if (now > sent_versions_at && (now - sent_versions_at) < 180) {
|
||||||
|
/* If we have gotten the NETINFO cell reasonably soon after having
|
||||||
|
* sent our VERSIONS cell, maybe we can learn skew information from it. */
|
||||||
apparent_skew = now - timestamp;
|
apparent_skew = now - timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1801,7 +1817,7 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
|
||||||
/* Act on apparent skew. */
|
/* Act on apparent skew. */
|
||||||
/** Warn when we get a netinfo skew with at least this value. */
|
/** Warn when we get a netinfo skew with at least this value. */
|
||||||
#define NETINFO_NOTICE_SKEW 3600
|
#define NETINFO_NOTICE_SKEW 3600
|
||||||
if (labs(apparent_skew) > NETINFO_NOTICE_SKEW &&
|
if (time_abs(apparent_skew) > NETINFO_NOTICE_SKEW &&
|
||||||
(started_here ||
|
(started_here ||
|
||||||
connection_or_digest_is_known_relay(chan->conn->identity_digest))) {
|
connection_or_digest_is_known_relay(chan->conn->identity_digest))) {
|
||||||
int trusted = router_digest_is_trusted_dir(chan->conn->identity_digest);
|
int trusted = router_digest_is_trusted_dir(chan->conn->identity_digest);
|
||||||
|
|
Loading…
Add table
Reference in a new issue