drogue-iot / embedded-tls

An Rust TLS 1.3 implementation for embedded devices.
Apache License 2.0
172 stars 22 forks source link

Fix blocking when reading into empty buffer #130

Closed bugadani closed 11 months ago

bugadani commented 11 months ago

embedded_io::Read specifies that reading into an empty buffer does not block.

If buf.len() == 0, read returns without blocking, with either Ok(0) or an error. The Ok(0) doesn’t indicate EOF, unlike when called with a non-empty buffer.

We implemented read in terms of the semantics of BufRead which blocks if there are no bytes available. This is incorrect in that we need to check if we actually have to wait for any bytes to be loaded.