diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-02-27 11:25:34 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-02-27 11:25:34 -0500 |
commit | c51919b0da2afe73780508e5593ebf9052e177cc (patch) | |
tree | 2dc3c47bf9beb1af0d77b9d195538a6fec9fc732 /src/or/dirserv.c | |
parent | 6747c62386964d961c3e98768e4dc9c51f8529de (diff) | |
parent | 074f24846321b8d08a8f67c37d72018842274c4e (diff) | |
download | tor-c51919b0da2afe73780508e5593ebf9052e177cc.tar.gz tor-c51919b0da2afe73780508e5593ebf9052e177cc.zip |
Merge branch 'bug21369_check_029_squashed' into maint-0.3.0
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index af01f8c283..f01668adcb 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -3658,8 +3658,14 @@ connection_dirserv_add_dir_bytes_to_outbuf(dir_connection_t *conn) if (bytes < 8192) bytes = 8192; remaining = conn->cached_dir->dir_z_len - conn->cached_dir_offset; - if (bytes > remaining) + if (BUG(remaining < 0)) { + remaining = 0; + } + if (bytes > remaining) { bytes = (ssize_t) remaining; + if (BUG(bytes < 0)) + return -1; + } if (conn->zlib_state) { connection_write_to_buf_zlib( @@ -3670,7 +3676,7 @@ connection_dirserv_add_dir_bytes_to_outbuf(dir_connection_t *conn) bytes, TO_CONN(conn)); } conn->cached_dir_offset += bytes; - if (conn->cached_dir_offset == (int)conn->cached_dir->dir_z_len) { + if (conn->cached_dir_offset >= (off_t)conn->cached_dir->dir_z_len) { /* We just wrote the last one; finish up. */ connection_dirserv_finish_spooling(conn); cached_dir_decref(conn->cached_dir); |