summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-06-24 10:48:14 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-06-24 10:48:14 -0400
commitbc50f082bd3a84156dd12db9e2186fd083b216c1 (patch)
tree36f0c74a6ee613a3a2fc5b2708e18a69a2710184
parent2eae59e475168c3056cd33d6ead4f384be915ec7 (diff)
parent3adabaf3e925f3ad395a2a0a2dbc92aa1d018ec4 (diff)
downloadtor-bc50f082bd3a84156dd12db9e2186fd083b216c1.tar.gz
tor-bc50f082bd3a84156dd12db9e2186fd083b216c1.zip
Merge branch 'tor-github/pr/1944'
-rw-r--r--changes/ticket400066
-rw-r--r--src/lib/tls/buffers_tls.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/changes/ticket40006 b/changes/ticket40006
new file mode 100644
index 0000000000..ad10e236c3
--- /dev/null
+++ b/changes/ticket40006
@@ -0,0 +1,6 @@
+ o Major bugfix (TLS, buffer):
+ - When attempting to read N bytes on a TLS connection, really try to read
+ those N bytes. Before that, Tor would stop reading after the first TLS
+ record which can be smaller than N bytes even though more data was waiting
+ on the TLS connection socket. The remaining data would have been read at
+ the next mainloop event. Fixes bug 40006; bugfix on 0.1.0.5-rc.
diff --git a/src/lib/tls/buffers_tls.c b/src/lib/tls/buffers_tls.c
index b92a14d6a1..1b99467d2b 100644
--- a/src/lib/tls/buffers_tls.c
+++ b/src/lib/tls/buffers_tls.c
@@ -59,6 +59,9 @@ read_to_chunk_tls(buf_t *buf, chunk_t *chunk, tor_tls_t *tls,
* Second, the TLS stream's events do not correspond directly to network
* events: sometimes, before a TLS stream can read, the network must be
* ready to write -- or vice versa.
+ *
+ * On success, return the number of bytes read. On error, a TOR_TLS_* negative
+ * code is returned (expect any of them except TOR_TLS_DONE).
*/
int
buf_read_from_tls(buf_t *buf, tor_tls_t *tls, size_t at_most)
@@ -92,8 +95,6 @@ buf_read_from_tls(buf_t *buf, tor_tls_t *tls, size_t at_most)
return r; /* Error */
tor_assert(total_read+r <= BUF_MAX_LEN);
total_read += r;
- if ((size_t)r < readlen) /* eof, block, or no more to read. */
- break;
}
return (int)total_read;
}