summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-06-26 09:39:59 -0400
committerNick Mathewson <nickm@torproject.org>2017-06-26 09:39:59 -0400
commitb546d8bc2bfa0e20bdd14181a29a91ba31df2f0e (patch)
treea2cefa7e3ac7fe0b6621aac3550cc8dcaa31ddd3 /src/or/buffers.c
parent2c49a9852dd7b8241f823ea0a0c8d90581518c7d (diff)
downloadtor-b546d8bc2bfa0e20bdd14181a29a91ba31df2f0e.tar.gz
tor-b546d8bc2bfa0e20bdd14181a29a91ba31df2f0e.zip
Try a little harder to make sure we never call tor_compress_process wrong.
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 3692ed4d08..12a6c0239b 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -2092,7 +2092,7 @@ fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len)
int
write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
const char *data, size_t data_len,
- int done)
+ const int done)
{
char *next;
size_t old_avail, avail;
@@ -2114,8 +2114,10 @@ write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
case TOR_COMPRESS_ERROR:
return -1;
case TOR_COMPRESS_OK:
- if (data_len == 0)
+ if (data_len == 0) {
+ tor_assert_nonfatal(!done);
over = 1;
+ }
break;
case TOR_COMPRESS_BUFFER_FULL:
if (avail) {
@@ -2124,6 +2126,11 @@ write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
* whether were going to or not. */
need_new_chunk = 1;
}
+ if (data_len == 0 && !done) {
+ /* We've consumed all the input data, though, so there's no
+ * point in forging ahead right now. */
+ over = 1;
+ }
break;
}
buf->datalen += old_avail - avail;