# std.crypto.tls.Client.readvAdvanced: fix bugs · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7cf2cbb33ef34c1d211135f56d30fe23b6cacd42)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42

Requested commit: 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42

Commit: 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42

Tree: e02fdfd1b337c556c544f4c0202e48da28827c29

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.crypto.tls.Client.readvAdvanced: fix bugs

 * When there is buffered cleartext, return it without calling the
   underlying read function. This prevents buffer overflow due to space
   used up by cleartext.
 * Avoid clearing the buffer when the buffered cleartext could not be
   completely given to the result read buffer, and there is some
   buffered ciphertext left.
 * Instead of rounding up the amount of bytes to ask for to the nearest
   TLS record size, round down, with a minimum of 1. This prevents the
   code path from being taken which requires extra memory copies.
 * Avoid calling `@memcpy` with overlapping arguments.

closes #15590

```

## Parents

- [378264d404e71da878f9e6934c045ad64193877f](https://git.cafe/gitcafe/zig/commit/378264d404e71da878f9e6934c045ad64193877f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7cf2cbb33ef34c1d211135f56d30fe23b6cacd42?format=markdown)
