Skip to content
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

Workaround SSLSocket always clearing the buffer #193

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

casperisfine
Copy link
Collaborator

Fix: #190

buff = "blah".b
p io.read_nonblock(10, buffer, exception: false) # :wait_readable
p buff

The above code when using a regular Ruby IO socket leaves the buffer intact, because it only replaces the content if it actually read something.

However when using a SSLSocket, the buffer is always cleared regardless of whether something was read or not.

This difference could cause the offset to be corrupted by pointing forward.

NB: not too sure how to regression test this.

Fix: #190

```ruby
buff = "blah".b
p io.read_nonblock(10, buffer, exception: false) # :wait_readable
p buff
```

The above code when using a regular Ruby IO socket leaves the
buffer intact, because it only replaces the content if it actually
read something.

However when using a `SSLSocket`, the buffer is always cleared
regardless of whether something was read or not.

This difference could cause the offset to be corrupted by pointing
forward.
@casperisfine casperisfine force-pushed the workaround-ssl-socket-buffer-clear branch from 1121770 to 98b8944 Compare April 16, 2024 11:28
@casperisfine casperisfine force-pushed the workaround-ssl-socket-buffer-clear branch from ed9ae98 to 49b0d16 Compare April 16, 2024 12:22
@casperisfine casperisfine merged commit 336ce1c into master Apr 16, 2024
25 of 26 checks passed
@casperisfine casperisfine deleted the workaround-ssl-socket-buffer-clear branch April 16, 2024 12:27
@casperisfine
Copy link
Collaborator Author

Upstream PR: ruby/openssl#739

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.

RedisClient::ProtocolError: Unknown sigil type: "\r"
2 participants