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

Fix segmentation fault on SSL_read due to null SSLState #2238

merged 5 commits into from Dec 8, 2018


None yet
2 participants
Copy link

commented Dec 6, 2018

While testing the HTTP/2 module there were some cases in which reading from a OpenSSLStream failed with a segmentation fault. This is due to the fact that the underlying SSLState gets freed when receiving a close_notify alert from TLS.

The SIGSEV was caused by the usage of a null m_tls state which would be passed to SSL_read and SSL_peek, resulting in a memory corruption. An easy fix for this is to add checks for null in both and OpenSSLStream.leastSize() and since both methods are supposed to return an integral, return 0 instead.

@@ -336,6 +338,7 @@ final class OpenSSLStream : TLSStream {
size_t read(scope ubyte[] dst, IOMode mode)
size_t nbytes = 0;
if(m_tls == null) return 0;

This comment has been minimized.

Copy link

s-ludwig Dec 6, 2018


This one should throw an exception instead (e.g. new Exception("Reading from closed TLS stream")).

@s-ludwig s-ludwig merged commit 056a9a9 into vibe-d:master Dec 8, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
continuous-integration/appveyor/pr AppVeyor build succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.