diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2021-12-01 23:20:17 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-02-22 19:28:35 +0000 |
commit | 86f81abe3043f273d3aa7166c72d100484af9d73 (patch) | |
tree | c3b3a857184f4a1415b92fad7b28ed697ced805d /src | |
parent | b2553bfba28b2e26f09041a3d78fa39c35fd4ac8 (diff) | |
download | tor-86f81abe3043f273d3aa7166c72d100484af9d73.tar.gz tor-86f81abe3043f273d3aa7166c72d100484af9d73.zip |
Properly compute the number or recv cells from deliver_window
Without this conversion, there is an implict 1000-recv_cells, which causes
the mod to fail if it is not a factor of 1000.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/or/sendme.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/or/sendme.c b/src/core/or/sendme.c index ee670f9d51..9acef1cc20 100644 --- a/src/core/or/sendme.c +++ b/src/core/or/sendme.c @@ -339,7 +339,7 @@ record_cell_digest_on_circ(circuit_t *circ, const uint8_t *sendme_digest) * updated once the cell is actually put in the outbuf. */ static bool -circuit_sendme_cell_is_next(int window, int sendme_inc) +circuit_sendme_cell_is_next(int deliver_window, int sendme_inc) { /* Are we at the limit of the increment and if not, we don't expect next * cell is a SENDME. @@ -348,8 +348,13 @@ circuit_sendme_cell_is_next(int window, int sendme_inc) * next cell is a SENDME, the window (either package or deliver) hasn't been * decremented just yet so when this is called, we are currently processing * the "window - 1" cell. + * + * Because deliver_window starts at CIRCWINDOW_START and counts down, + * to get the actual number of received cells for this check, we must + * first convert to receieved cells, or the modulus operator will fail. */ - if (((window - 1) % sendme_inc) != 0) { + tor_assert(deliver_window <= CIRCWINDOW_START); + if (((CIRCWINDOW_START - (deliver_window - 1)) % sendme_inc) != 0) { return false; } |