Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9d3fd51f850d
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dcf47e8ad8f2
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Feb 10, 2017

  1. Fix: close IO on OpenSSL accept failure

    This avoids leaving a socket in an indeterminate state opened longer
    than necessary.
    
    fixes #3953
    ysbaddaden authored and Santiago Palladino committed Feb 10, 2017
    Copy the full SHA
    18d3b6f View commit details
  2. Fix: HTTP server raises when TLS socket is normally closed

    HTTP::Server defaults to a keepalive connection (as expected by the
    spec), but the connection may be closed normally while HTTP::Request
    is waiting to receive a new request to process, yet
    `OpenSSL::SSL::Socket#read` raised an exception instead of returning
    `0` to report an EOF.
    ysbaddaden authored and Santiago Palladino committed Feb 10, 2017
    Copy the full SHA
    e5273bd View commit details
  3. Fix: buffered IO won't close if flushing failed

    IO::Buffered tries to flush pending data when it's closed, but if
    flushing fails, it won't try to close the IO, which could lead to
    leaking file descriptors.
    ysbaddaden authored and Santiago Palladino committed Feb 10, 2017
    Copy the full SHA
    dcf47e8 View commit details
Showing with 5 additions and 3 deletions.
  1. +2 −2 src/io/buffered.cr
  2. +3 −1 src/openssl/ssl/socket.cr
4 changes: 2 additions & 2 deletions src/io/buffered.cr
Original file line number Diff line number Diff line change
@@ -190,10 +190,10 @@ module IO::Buffered
end

# Flushes and closes the underlying `IO`.
def close
def close : Nil
flush if @out_count > 0
ensure
unbuffered_close
nil
end

# Rewinds the underlying `IO`. Returns `self`.
4 changes: 3 additions & 1 deletion src/openssl/ssl/socket.cr
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ abstract class OpenSSL::SSL::Socket

ret = LibSSL.ssl_accept(@ssl)
unless ret == 1
io.close if sync_close
raise OpenSSL::SSL::Error.new(@ssl, ret, "SSL_accept")
end
end
@@ -95,8 +96,9 @@ abstract class OpenSSL::SSL::Socket

count = slice.size
return 0 if count == 0

LibSSL.ssl_read(@ssl, slice.pointer(count), count).tap do |bytes|
unless bytes > 0
if bytes <= 0 && !LibSSL.ssl_get_error(@ssl, bytes).zero_return?
raise OpenSSL::SSL::Error.new(@ssl, bytes, "SSL_read")
end
end