redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
124 stars 60 forks source link

Workaround SSLSocket always clearing the buffer #193

Closed casperisfine closed 6 months ago

casperisfine commented 6 months ago

Fix: https://github.com/redis-rb/redis-client/issues/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.

casperisfine commented 6 months ago

Upstream PR: https://github.com/ruby/openssl/pull/739