tor/src
David Goulet 3adabaf3e9 tls: Make buf_read_from_tls() read at most bytes
The buf_read_from_tls() function was designed to read up to a certain number
of bytes a TLS socket using read_to_chunk_tls() which boils down to SSL_read()
(with OpenSSL, common case).

However, at the end of the loop, the returned number of bytes from
read_to_chunk_tls() was treated like the syscall read() for which if less
bytes than the total asked are returned, it signals EOF.

But, with SSL_read(), it returns up to a TLS record which can be less than
what was asked. The assumption that it was EOF was wrong which made the while
loop exiting before it was able to consume all requested bytes (at_most
parameter).

The general use case that Tor sees is that it will ask the network layer to
give it at most 16KB (that is roughly 32 cells) but because of KIST scheduler,
the highest possible TLS record we currently observe is 4096 bytes (4KB or 8
cells). Thus the loop would at best always return 8 cells even though much
more could be on the TLS socket. See ticket #40006 for more details.

Fixes #40006

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 10:47:53 -04:00
..
app Remove AssumeReachable from TestingTorNetwork. 2020-06-15 14:08:42 -04:00
config python: Add __future__ imports for python 3 compatibility 2019-12-12 15:58:51 +10:00
core core: Remove unused files 2020-06-12 14:40:49 -04:00
ext Merge branch 'maint-0.4.3' 2020-05-06 16:55:41 -04:00
feature Merge branch 'maint-0.4.4' 2020-06-11 17:29:54 +03:00
lib tls: Make buf_read_from_tls() read at most bytes 2020-06-24 10:47:53 -04:00
rust rust/protover: Fix protocol version support error handling 2020-05-18 21:50:35 +10:00
test Merge branch 'maint-0.4.4' 2020-06-11 17:29:54 +03:00
tools net: Make all address bytes functions take uint8_t * 2020-04-30 06:54:42 +10:00
trunnel Update Trunnel for new machine_ctr field. 2020-06-08 18:05:34 -05:00
win32 Bump version to 0.4.5.0-alpha-dev 2020-06-09 14:14:43 -04:00
arch_goals.md Document high-level architecture goals 2019-12-10 16:47:38 -06:00
include.am Move winprocess_sys into a new low-level hardening module 2020-02-24 07:49:39 -05:00
mainpage.md doxygen: add a link to src-ref on mainpage.md. 2020-05-19 09:44:36 -04:00