Skip to content

tls.Client: fix out of bounds panic #20587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Conversation

ianic
Copy link
Contributor

@ianic ianic commented Jul 11, 2024

When calculating how much ciphertext from the stream can fit into user and internal buffers we should also take into account ciphertext data which are already in internal buffer.

Fixes: #15226

Tested with this. Using client with different read buffers until I, hopefully, understood what is happening.

Not relevant to the fix, but this part is still mystery to me. Why we don't use free_size in buf_cap calculation. Seems like rudiment from previous implementation without iovec.

When calculating how much ciphertext from the stream can fit into
user and internal buffers we should also take into account ciphertext
data which are already in internal buffer.

Fixes: 15226

Tested with
[this](ziglang#15226 (comment)).
Using client with different read buffers until I, hopefully, understood
what is happening.

Not relevant to this fix, but this
[part](https://github.com/ziglang/zig/blob/95d9292a7a09ed883e65510ec054619747315c48/lib/std/crypto/tls/Client.zig#L988-L991)
is still mystery to me. Why we don't use free_size in buf_cap
calculation. Seems like rudiment from previous implementation without iovec.
@andrewrk andrewrk merged commit ca752c6 into ziglang:master Jul 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sporadic 'index out of bounds' panic in tls client
2 participants